یلدا ادامه داره... ❤️ ۴۰ درصد تخفیف همه دورهها
استفاده از تخفیفهادرود به همگی
بنده فایل هامو روی هاست قرار دادم و حالا هنگامی که مسیرها اشاره میکنم یکی از مسیرهام پیغام زیر رو نمایش میده .
ReflectionException (-1)
Class App\Http\Controllers\API\ArticleController does not exist
در صورتی که مسیرهای دیگه به راحتی json ها نمایش داده می شود.
rout ها به صورت زیر تعریف شده است.
Route::resource('articles','API\ArticleController');
Route::resource('files','API\MyFileController');
و همچنین ArticleController من به صورت زیر است
<?php
namespace App\Http\Controllers\Api;
use App\Article;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ArticleController extends Controller
{
/
Display a listing of the resource.
@return \Illuminate\Http\Response
/
public function index()
{
$articles=Article::all();
return response()->json($articles,200);
}
/
Show the form for creating a new resource.
@return \Illuminate\Http\Response
/
public function create()
{
//
}
/
Store a newly created resource in storage.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response
/
public function store(Request $request)
{
$validation=$this->getValidationFactory()->make($request->all(),[
'title'=>'required|max:255',
'text_content'=>'required',
'category'=>'required|max:10',
'image_2'=>'mimes:jpeg,png',
'image_3'=>'mimes:jpeg,png',
'image_4'=>'mimes:jpeg,png',
'image_5'=>'mimes:jpeg,png',
'image_6'=>'mimes:jpeg,png',
'image_7'=>'mimes:jpeg,png',
]);
if ($validation->fails()){
return response()->json(['Message'=>'please feel necessary field'],400);
}
$article=new Article();
$article->title=$request->title;
$article->text_content=$request->text_content;
$article->category=$request->category;
$article->image_2=$request->image_2;
$article->image_3=$request->image_3;
$article->image_4=$request->image_4;
$article->image_5=$request->image_5;
$article->image_6=$request->image_6;
$article->image_7=$request->image_7;
if ($article->save()){
if(!$request->image_2==null) {
$name2 = 'article-' . $article->id . '.' . $request->file('image_2')->getClientOriginalExtension();
$request->file('image_2')->move(public_path('images'), $name2);
$article->image_2 = $name2;
}
if(!$request->image_3==null) {
$name3 = 'article-' . $article->id . '.' . $request->file('image_3')->getClientOriginalExtension();
$request->file('image_3')->move(public_path('images'), $name3);
$article->image_3 = $name3;
}
if(!$request->image_4==null) {
$name4 = 'article-' . $article->id . '.' . $request->file('image_4')->getClientOriginalExtension();
$request->file('image_4')->move(public_path('images'), $name4);
$article->image_4 = $name4;
}
if(!$request->image_5==null) {
$name5 = 'article-' . $article->id . '.' . $request->file('image_5')->getClientOriginalExtension();
$request->file('image_5')->move(public_path('images'), $name5);
$article->image_5 = $name5;
}
if(!$request->image_6==null) {
$name6 = 'article-' . $article->id . '.' . $request->file('image_6')->getClientOriginalExtension();
$request->file('image_6')->move(public_path('images'), $name6);
$article->image_6 = $name6;
}
if(!$request->image_7==null){
$name7 = 'article-' . $article->id . '.' . $request->file('image_7')->getClientOriginalExtension();
$request->file('image_7')->move(public_path('images'), $name7);
$article->image_7 = $name7;
}
$article->save();
return response()->json(['Message'=>'saved successfully'],200);
}
}
/
Display the specified resource.
@param int $id
@return \Illuminate\Http\Response
/
public function show($id)
{
$article=Article::find($id);
if (!$article){
return response()->json(['Message'=>'Article not found'],404);
}
return response()->json($article,200);
}
/
Show the form for editing the specified resource.
@param int $id
@return \Illuminate\Http\Response
/
public function edit($id)
{
//
}
/
Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response
/
public function update(Request $request, $id)
{
// $validation=$this->getValidationFactory()->make($request->all(),[
// 'title'=>'required|max:255',
// 'text_content'=>'required',
// 'category'=>'required|max:10',
//// 'image_2'=>'mimes:jpeg,png',
//// 'image_3'=>'mimes:jpeg,png',
//// 'image_4'=>'mimes:jpeg,png',
//// 'image_5'=>'mimes:jpeg,png',
//// 'image_6'=>'mimes:jpeg,png',
//// 'image_7'=>'mimes:jpeg,png',
// ]);
// if ($validation->fails()){
// return response()->json(['Message'=>'please feel necessary field'],400);
// }
$article=Article::find($id);
$article->title=$request->title;
$article->text_content=$request->text_content;
$article->category=$request->category;
$article->image_2=$request->image_2;
$article->image_3=$request->image_3;
$article->image_4=$request->image_4;
$article->image_5=$request->image_5;
$article->image_6=$request->image_6;
$article->image_7=$request->image_7;
if ($article->save()){
if(!$request->image_2==null) {
$name2 = 'article-' . $article->id . '.' . $request->file('image_2')->getClientOriginalExtension();
$request->file('image_2')->move(public_path('images'), $name2);
$article->image_2 = $name2;
}
if(!$request->image_3==null) {
$name3 = 'article-' . $article->id . '.' . $request->file('image_3')->getClientOriginalExtension();
$request->file('image_3')->move(public_path('images'), $name3);
$article->image_3 = $name3;
}
if(!$request->image_4==null) {
$name4 = 'article-' . $article->id . '.' . $request->file('image_4')->getClientOriginalExtension();
$request->file('image_4')->move(public_path('images'), $name4);
$article->image_4 = $name4;
}
if(!$request->image_5==null) {
$name5 = 'article-' . $article->id . '.' . $request->file('image_5')->getClientOriginalExtension();
$request->file('image_5')->move(public_path('images'), $name5);
$article->image_5 = $name5;
}
if(!$request->image_6==null) {
$name6 = 'article-' . $article->id . '.' . $request->file('image_6')->getClientOriginalExtension();
$request->file('image_6')->move(public_path('images'), $name6);
$article->image_6 = $name6;
}
if(!$request->image_7==null){
$name7 = 'article-' . $article->id . '.' . $request->file('image_7')->getClientOriginalExtension();
$request->file('image_7')->move(public_path('images'), $name7);
$article->image_7 = $name7;
}
$article->save();
return response()->json(['Message'=>'saved successfully'],200);
}
}
/
Remove the specified resource from storage.
@param int $id
@return \Illuminate\Http\Response
/
public function destroy($id)
{
Article::find($id)->delete();
return response()->json(['Message'=>'delete successfully'],200);
}
}
ممنون میشم راهنمایی کنید .
@hesammousavi @ali.bayat
سلام.
احتمالا مشکل حساس بودن لینکوس به حروف بزرگ و کوچیکه.
اسم پوشه API داخل Httpرو شما توی روت هاتون به صورت حروف بزرگ گذاشتین در صورتی که اسم پوشه Api هست.
احتمالا با کار زیر مشکلتون حل میشه.
Route::resource('articles','Api\ArticleController');
Route::resource('files','Api\MyFileController');
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟