Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

C++ JAVA
Post Reply
User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Ticketa » Wed Oct 14, 2020 7:43 pm

На какво може да се дължи тази грешка:
BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Много странно. Един път всичко си работи коректно - добавям в плъзгача нов елемент, редактирам, изтривам, добавям променям.... и в следващия момент се получава тази грешка:

BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

/public_html/.htaccess

Code: Select all

#
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On


RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1 
RewriteRule ^storage(/|$) /public%{REQUEST_URI} [L,NC,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
routes.php

Code: Select all

<?php

// FRONT-END ROUTES
Route::get('/', 'FrontpageController@index')->name('home');
Route::get('/slider', 'FrontpageController@slider')->name('slider.index');

Route::get('/search', 'FrontpageController@search')->name('search');

Route::get('/property', 'PagesController@properties')->name('property');
Route::get('/property/{id}', 'PagesController@propertieshow')->name('property.show');
Route::post('/property/message', 'PagesController@messageAgent')->name('property.message');
Route::post('/property/comment/{id}', 'PagesController@propertyComments')->name('property.comment');
Route::post('/property/rating', 'PagesController@propertyRating')->name('property.rating');
Route::get('/property/city/{cityslug}', 'PagesController@propertyCities')->name('property.city');

Route::get('/agents', 'PagesController@agents')->name('agents');
Route::get('/agents/{id}', 'PagesController@agentshow')->name('agents.show');

Route::get('/gallery', 'PagesController@gallery')->name('gallery');

Route::get('/blog', 'PagesController@blog')->name('blog');
Route::get('/blog/{id}', 'PagesController@blogshow')->name('blog.show');
Route::post('/blog/comment/{id}', 'PagesController@blogComments')->name('blog.comment');

Route::get('/blog/categories/{slug}', 'PagesController@blogCategories')->name('blog.categories');
Route::get('/blog/tags/{slug}', 'PagesController@blogTags')->name('blog.tags');
Route::get('/blog/author/{username}', 'PagesController@blogAuthor')->name('blog.author');

Route::get('/contact', 'PagesController@contact')->name('contact');
Route::post('/contact', 'PagesController@messageContact')->name('contact.message');


Auth::routes();

Route::group(['prefix'=>'admin','namespace'=>'Admin','middleware'=>['auth','admin'],'as'=>'admin.'], function(){

    Route::get('/', 'DashboardController@index')->name('dashboard');
    Route::get('dashboard','DashboardController@index')->name('dashboard');
    Route::resource('tags','TagController');
    Route::resource('categories','CategoryController');
    Route::resource('posts','PostController');
    Route::resource('features','FeatureController');
    Route::resource('properties','PropertyController');
    Route::post('properties/gallery/delete','PropertyController@galleryImageDelete')->name('gallery-delete');

    Route::resource('sliders','SliderController');
    Route::resource('services','ServiceController');
    Route::resource('testimonials','TestimonialController');

    Route::get('galleries/album','GalleryController@album')->name('album');
    Route::post('galleries/album/store','GalleryController@albumStore')->name('album.store');
    Route::get('galleries/{id}/gallery','GalleryController@albumGallery')->name('album.gallery');
    Route::post('galleries','GalleryController@Gallerystore')->name('galleries.store');

    Route::get('settings', 'DashboardController@settings')->name('settings');
    Route::post('settings', 'DashboardController@settingStore')->name('settings.store');

    Route::get('profile','DashboardController@profile')->name('profile');
    Route::post('profile','DashboardController@profileUpdate')->name('profile.update');

    Route::get('message','DashboardController@message')->name('message');
    Route::get('message/read/{id}','DashboardController@messageRead')->name('message.read');
    Route::get('message/replay/{id}','DashboardController@messageReplay')->name('message.replay');
    Route::post('message/replay','DashboardController@messageSend')->name('message.send');
    Route::post('message/readunread','DashboardController@messageReadUnread')->name('message.readunread');
    Route::delete('message/delete/{id}','DashboardController@messageDelete')->name('messages.destroy');
    Route::post('message/mail', 'DashboardController@contactMail')->name('message.mail');

    Route::get('changepassword','DashboardController@changePassword')->name('changepassword');
    Route::post('changepassword','DashboardController@changePasswordUpdate')->name('changepassword.update');

});

Route::group(['prefix'=>'agent','namespace'=>'Agent','middleware'=>['auth','agent'],'as'=>'agent.'], function(){

    Route::get('dashboard','DashboardController@index')->name('dashboard');
    Route::get('profile','DashboardController@profile')->name('profile');
    Route::post('profile','DashboardController@profileUpdate')->name('profile.update');
    Route::get('changepassword','DashboardController@changePassword')->name('changepassword');
    Route::post('changepassword','DashboardController@changePasswordUpdate')->name('changepassword.update');
    Route::resource('properties','PropertyController');
    Route::post('properties/gallery/delete','PropertyController@galleryImageDelete')->name('gallery-delete');

    Route::get('message','DashboardController@message')->name('message');
    Route::get('message/read/{id}','DashboardController@messageRead')->name('message.read');
    Route::get('message/replay/{id}','DashboardController@messageReplay')->name('message.replay');
    Route::post('message/replay','DashboardController@messageSend')->name('message.send');
    Route::post('message/readunread','DashboardController@messageReadUnread')->name('message.readunread');
    Route::delete('message/delete/{id}','DashboardController@messageDelete')->name('messages.destroy');
    Route::post('message/mail', 'DashboardController@contactMail')->name('message.mail');

});

Route::group(['prefix'=>'user','namespace'=>'User','middleware'=>['auth','user'],'as'=>'user.'], function(){

    Route::get('dashboard','DashboardController@index')->name('dashboard');
    Route::get('profile','DashboardController@profile')->name('profile');
    Route::post('profile','DashboardController@profileUpdate')->name('profile.update');
    Route::get('changepassword','DashboardController@changePassword')->name('changepassword');
    Route::post('changepassword','DashboardController@changePasswordUpdate')->name('changepassword.update');

    Route::get('message','DashboardController@message')->name('message');
    Route::get('message/read/{id}','DashboardController@messageRead')->name('message.read');
    Route::get('message/replay/{id}','DashboardController@messageReplay')->name('message.replay');
    Route::post('message/replay','DashboardController@messageSend')->name('message.send');
    Route::post('message/readunread','DashboardController@messageReadUnread')->name('message.readunread');
    Route::delete('message/delete/{id}','DashboardController@messageDelete')->name('messages.destroy');

});
public/.htaccess

Code: Select all

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
/app/Http/Controllers/Admin/SliderController.php

Code: Select all

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use App\Slider;
use Carbon\Carbon;
use Toastr;

class SliderController extends Controller
{
    public function index()
    {
        $sliders = Slider::latest()->get();

        return view('admin.sliders.index', compact('sliders'));
    }

    public function create()
    {
        return view('admin.sliders.create');
    }

    public function store(Request $request)
    {
        $request->validate([
            'title' => 'required|unique:sliders|max:255',
            'image' => 'required|mimes:jpeg,jpg,png'
        ]);

        $image = $request->file('image');
        $slug  = str_slug($request->title);

        if(isset($image)){
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();

            if(!Storage::disk('public')->exists('slider')){
                Storage::disk('public')->makeDirectory('slider');
            }
            $slider = Image::make($image)->resize(1600, 480)->save();
            Storage::disk('public')->put('slider/'.$imagename, $slider);
        }else{
            $imagename = 'default.png';
        }

        $slider = new Slider();
        $slider->title = $request->title;
        $slider->description = $request->description;
        $slider->image = $imagename;
        $slider->save();

        Toastr::success('message', 'Slider created successfully.');
        return redirect()->route('admin.sliders.index');
    }


    public function edit($id)
    {
        $slider = Slider::find($id);

        return view('admin.sliders.edit', compact('slider'));
    }


    public function update(Request $request, $id)
    {
        $request->validate([
            'title' => 'required|max:255',
            'image' => 'mimes:jpeg,jpg,png'
        ]);

        $image = $request->file('image'); 
        $slug  = str_slug($request->title);
        $slider = Slider::find($id);

        if(isset($image)){
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
            if(!Storage::disk('public')->exists('slider')){
                Storage::disk('public')->makeDirectory('slider');
            }
            if(Storage::disk('public')->exists('slider/'.$slider->image)){
                Storage::disk('public')->delete('slider/'.$slider->image);
            }
            $sliderimg = Image::make($image)->resize(1600, 480)->save();
            Storage::disk('public')->put('slider/'.$imagename, $sliderimg);
        }else{
            $imagename = $slider->image;
        }

        $slider->title = $request->title;
        $slider->description = $request->description;
        $slider->image = $imagename;
        $slider->save();

        Toastr::success('message', 'Slider updated successfully.');
        return redirect()->route('admin.sliders.index');
    }


    public function destroy($id)
    {
        $slider = Slider::find($id);

        if(Storage::disk('public')->exists('slider/'.$slider->image)){
            Storage::disk('public')->delete('slider/'.$slider->image);
        }

        $slider->delete();

        Toastr::success('message', 'Slider deleted successfully.');
        return back();
    }
}


php artisan route:list
+--------+-----------+---------------------------------------+-----------------------------+------------------------------------------------------------------------+----------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+---------------------------------------+-----------------------------+------------------------------------------------------------------------+----------------+
| | GET|HEAD | / | home | App\Http\Controllers\FrontpageController@index | web |
| | GET|HEAD | admin | admin.dashboard | App\Http\Controllers\Admin\DashboardController@index | web,auth,admin |
| | POST | admin/categories | admin.categories.store | App\Http\Controllers\Admin\CategoryController@store | web,auth,admin |
| | GET|HEAD | admin/categories | admin.categories.index | App\Http\Controllers\Admin\CategoryController@index | web,auth,admin |
| | GET|HEAD | admin/categories/create | admin.categories.create | App\Http\Controllers\Admin\CategoryController@create | web,auth,admin |
| | PUT|PATCH | admin/categories/{category} | admin.categories.update | App\Http\Controllers\Admin\CategoryController@update | web,auth,admin |
| | DELETE | admin/categories/{category} | admin.categories.destroy | App\Http\Controllers\Admin\CategoryController@destroy | web,auth,admin |
| | GET|HEAD | admin/categories/{category} | admin.categories.show | App\Http\Controllers\Admin\CategoryController@show | web,auth,admin |
| | GET|HEAD | admin/categories/{category}/edit | admin.categories.edit | App\Http\Controllers\Admin\CategoryController@edit | web,auth,admin |
| | POST | admin/changepassword | admin.changepassword.update | App\Http\Controllers\Admin\DashboardController@changePasswordUpdate | web,auth,admin |
| | GET|HEAD | admin/changepassword | admin.changepassword | App\Http\Controllers\Admin\DashboardController@changePassword | web,auth,admin |
| | GET|HEAD | admin/dashboard | admin.dashboard | App\Http\Controllers\Admin\DashboardController@index | web,auth,admin |
| | POST | admin/features | admin.features.store | App\Http\Controllers\Admin\FeatureController@store | web,auth,admin |
| | GET|HEAD | admin/features | admin.features.index | App\Http\Controllers\Admin\FeatureController@index | web,auth,admin |
| | GET|HEAD | admin/features/create | admin.features.create | App\Http\Controllers\Admin\FeatureController@create | web,auth,admin |
| | GET|HEAD | admin/features/{feature} | admin.features.show | App\Http\Controllers\Admin\FeatureController@show | web,auth,admin |
| | PUT|PATCH | admin/features/{feature} | admin.features.update | App\Http\Controllers\Admin\FeatureController@update | web,auth,admin |
| | DELETE | admin/features/{feature} | admin.features.destroy | App\Http\Controllers\Admin\FeatureController@destroy | web,auth,admin |
| | GET|HEAD | admin/features/{feature}/edit | admin.features.edit | App\Http\Controllers\Admin\FeatureController@edit | web,auth,admin |
| | POST | admin/galleries | admin.galleries.store | App\Http\Controllers\Admin\GalleryController@Gallerystore | web,auth,admin |
| | GET|HEAD | admin/galleries/album | admin.album | App\Http\Controllers\Admin\GalleryController@album | web,auth,admin |
| | POST | admin/galleries/album/store | admin.album.store | App\Http\Controllers\Admin\GalleryController@albumStore | web,auth,admin |
| | GET|HEAD | admin/galleries/{id}/gallery | admin.album.gallery | App\Http\Controllers\Admin\GalleryController@albumGallery | web,auth,admin |
| | GET|HEAD | admin/message | admin.message | App\Http\Controllers\Admin\DashboardController@message | web,auth,admin |
| | DELETE | admin/message/delete/{id} | admin.messages.destroy | App\Http\Controllers\Admin\DashboardController@messageDelete | web,auth,admin |
| | POST | admin/message/mail | admin.message.mail | App\Http\Controllers\Admin\DashboardController@contactMail | web,auth,admin |
| | GET|HEAD | admin/message/read/{id} | admin.message.read | App\Http\Controllers\Admin\DashboardController@messageRead | web,auth,admin |
| | POST | admin/message/readunread | admin.message.readunread | App\Http\Controllers\Admin\DashboardController@messageReadUnread | web,auth,admin |
| | POST | admin/message/replay | admin.message.send | App\Http\Controllers\Admin\DashboardController@messageSend | web,auth,admin |
| | GET|HEAD | admin/message/replay/{id} | admin.message.replay | App\Http\Controllers\Admin\DashboardController@messageReplay | web,auth,admin |
| | GET|HEAD | admin/posts | admin.posts.index | App\Http\Controllers\Admin\PostController@index | web,auth,admin |
| | POST | admin/posts | admin.posts.store | App\Http\Controllers\Admin\PostController@store | web,auth,admin |
| | GET|HEAD | admin/posts/create | admin.posts.create | App\Http\Controllers\Admin\PostController@create | web,auth,admin |
| | PUT|PATCH | admin/posts/{post} | admin.posts.update | App\Http\Controllers\Admin\PostController@update | web,auth,admin |
| | DELETE | admin/posts/{post} | admin.posts.destroy | App\Http\Controllers\Admin\PostController@destroy | web,auth,admin |
| | GET|HEAD | admin/posts/{post} | admin.posts.show | App\Http\Controllers\Admin\PostController@show | web,auth,admin |
| | GET|HEAD | admin/posts/{post}/edit | admin.posts.edit | App\Http\Controllers\Admin\PostController@edit | web,auth,admin |
| | POST | admin/profile | admin.profile.update | App\Http\Controllers\Admin\DashboardController@profileUpdate | web,auth,admin |
| | GET|HEAD | admin/profile | admin.profile | App\Http\Controllers\Admin\DashboardController@profile | web,auth,admin |
| | GET|HEAD | admin/properties | admin.properties.index | App\Http\Controllers\Admin\PropertyController@index | web,auth,admin |
| | POST | admin/properties | admin.properties.store | App\Http\Controllers\Admin\PropertyController@store | web,auth,admin |
| | GET|HEAD | admin/properties/create | admin.properties.create | App\Http\Controllers\Admin\PropertyController@create | web,auth,admin |
| | POST | admin/properties/gallery/delete | admin.gallery-delete | App\Http\Controllers\Admin\PropertyController@galleryImageDelete | web,auth,admin |
| | DELETE | admin/properties/{property} | admin.properties.destroy | App\Http\Controllers\Admin\PropertyController@destroy | web,auth,admin |
| | PUT|PATCH | admin/properties/{property} | admin.properties.update | App\Http\Controllers\Admin\PropertyController@update | web,auth,admin |
| | GET|HEAD | admin/properties/{property} | admin.properties.show | App\Http\Controllers\Admin\PropertyController@show | web,auth,admin |
| | GET|HEAD | admin/properties/{property}/edit | admin.properties.edit | App\Http\Controllers\Admin\PropertyController@edit | web,auth,admin |
| | GET|HEAD | admin/services | admin.services.index | App\Http\Controllers\Admin\ServiceController@index | web,auth,admin |
| | POST | admin/services | admin.services.store | App\Http\Controllers\Admin\ServiceController@store | web,auth,admin |
| | GET|HEAD | admin/services/create | admin.services.create | App\Http\Controllers\Admin\ServiceController@create | web,auth,admin |
| | PUT|PATCH | admin/services/{service} | admin.services.update | App\Http\Controllers\Admin\ServiceController@update | web,auth,admin |
| | GET|HEAD | admin/services/{service} | admin.services.show | App\Http\Controllers\Admin\ServiceController@show | web,auth,admin |
| | DELETE | admin/services/{service} | admin.services.destroy | App\Http\Controllers\Admin\ServiceController@destroy | web,auth,admin |
| | GET|HEAD | admin/services/{service}/edit | admin.services.edit | App\Http\Controllers\Admin\ServiceController@edit | web,auth,admin |
| | GET|HEAD | admin/settings | admin.settings | App\Http\Controllers\Admin\DashboardController@settings | web,auth,admin |
| | POST | admin/settings | admin.settings.store | App\Http\Controllers\Admin\DashboardController@settingStore | web,auth,admin |
| | POST | admin/sliders | admin.sliders.store | App\Http\Controllers\Admin\SliderController@store | web,auth,admin |
| | GET|HEAD | admin/sliders | admin.sliders.index | App\Http\Controllers\Admin\SliderController@index | web,auth,admin |
| | GET|HEAD | admin/sliders/create | admin.sliders.create | App\Http\Controllers\Admin\SliderController@create | web,auth,admin |
| | DELETE | admin/sliders/{slider} | admin.sliders.destroy | App\Http\Controllers\Admin\SliderController@destroy | web,auth,admin |
| | PUT|PATCH | admin/sliders/{slider} | admin.sliders.update | App\Http\Controllers\Admin\SliderController@update | web,auth,admin |
| | GET|HEAD | admin/sliders/{slider} | admin.sliders.show | App\Http\Controllers\Admin\SliderController@show | web,auth,admin |
| | GET|HEAD | admin/sliders/{slider}/edit | admin.sliders.edit | App\Http\Controllers\Admin\SliderController@edit | web,auth,admin |
| | GET|HEAD | admin/tags | admin.tags.index | App\Http\Controllers\Admin\TagController@index | web,auth,admin |
| | POST | admin/tags | admin.tags.store | App\Http\Controllers\Admin\TagController@store | web,auth,admin |
| | GET|HEAD | admin/tags/create | admin.tags.create | App\Http\Controllers\Admin\TagController@create | web,auth,admin |
| | DELETE | admin/tags/{tag} | admin.tags.destroy | App\Http\Controllers\Admin\TagController@destroy | web,auth,admin |
| | GET|HEAD | admin/tags/{tag} | admin.tags.show | App\Http\Controllers\Admin\TagController@show | web,auth,admin |
| | PUT|PATCH | admin/tags/{tag} | admin.tags.update | App\Http\Controllers\Admin\TagController@update | web,auth,admin |
| | GET|HEAD | admin/tags/{tag}/edit | admin.tags.edit | App\Http\Controllers\Admin\TagController@edit | web,auth,admin |
| | GET|HEAD | admin/testimonials | admin.testimonials.index | App\Http\Controllers\Admin\TestimonialController@index | web,auth,admin |
| | POST | admin/testimonials | admin.testimonials.store | App\Http\Controllers\Admin\TestimonialController@store | web,auth,admin |
| | GET|HEAD | admin/testimonials/create | admin.testimonials.create | App\Http\Controllers\Admin\TestimonialController@create | web,auth,admin |
| | PUT|PATCH | admin/testimonials/{testimonial} | admin.testimonials.update | App\Http\Controllers\Admin\TestimonialController@update | web,auth,admin |
| | GET|HEAD | admin/testimonials/{testimonial} | admin.testimonials.show | App\Http\Controllers\Admin\TestimonialController@show | web,auth,admin |
| | DELETE | admin/testimonials/{testimonial} | admin.testimonials.destroy | App\Http\Controllers\Admin\TestimonialController@destroy | web,auth,admin |
| | GET|HEAD | admin/testimonials/{testimonial}/edit | admin.testimonials.edit | App\Http\Controllers\Admin\TestimonialController@edit | web,auth,admin |
| | POST | agent/changepassword | agent.changepassword.update | App\Http\Controllers\Agent\DashboardController@changePasswordUpdate | web,auth,agent |
| | GET|HEAD | agent/changepassword | agent.changepassword | App\Http\Controllers\Agent\DashboardController@changePassword | web,auth,agent |
| | GET|HEAD | agent/dashboard | agent.dashboard | App\Http\Controllers\Agent\DashboardController@index | web,auth,agent |
| | GET|HEAD | agent/message | agent.message | App\Http\Controllers\Agent\DashboardController@message | web,auth,agent |
| | DELETE | agent/message/delete/{id} | agent.messages.destroy | App\Http\Controllers\Agent\DashboardController@messageDelete | web,auth,agent |
| | POST | agent/message/mail | agent.message.mail | App\Http\Controllers\Agent\DashboardController@contactMail | web,auth,agent |
| | GET|HEAD | agent/message/read/{id} | agent.message.read | App\Http\Controllers\Agent\DashboardController@messageRead | web,auth,agent |
| | POST | agent/message/readunread | agent.message.readunread | App\Http\Controllers\Agent\DashboardController@messageReadUnread | web,auth,agent |
| | POST | agent/message/replay | agent.message.send | App\Http\Controllers\Agent\DashboardController@messageSend | web,auth,agent |
| | GET|HEAD | agent/message/replay/{id} | agent.message.replay | App\Http\Controllers\Agent\DashboardController@messageReplay | web,auth,agent |
| | POST | agent/profile | agent.profile.update | App\Http\Controllers\Agent\DashboardController@profileUpdate | web,auth,agent |
| | GET|HEAD | agent/profile | agent.profile | App\Http\Controllers\Agent\DashboardController@profile | web,auth,agent |
| | GET|HEAD | agent/properties | agent.properties.index | App\Http\Controllers\Agent\PropertyController@index | web,auth,agent |
| | POST | agent/properties | agent.properties.store | App\Http\Controllers\Agent\PropertyController@store | web,auth,agent |
| | GET|HEAD | agent/properties/create | agent.properties.create | App\Http\Controllers\Agent\PropertyController@create | web,auth,agent |
| | POST | agent/properties/gallery/delete | agent.gallery-delete | App\Http\Controllers\Agent\PropertyController@galleryImageDelete | web,auth,agent |
| | GET|HEAD | agent/properties/{property} | agent.properties.show | App\Http\Controllers\Agent\PropertyController@show | web,auth,agent |
| | PUT|PATCH | agent/properties/{property} | agent.properties.update | App\Http\Controllers\Agent\PropertyController@update | web,auth,agent |
| | DELETE | agent/properties/{property} | agent.properties.destroy | App\Http\Controllers\Agent\PropertyController@destroy | web,auth,agent |
| | GET|HEAD | agent/properties/{property}/edit | agent.properties.edit | App\Http\Controllers\Agent\PropertyController@edit | web,auth,agent |
| | GET|HEAD | agents | agents | App\Http\Controllers\PagesController@agents | web |
| | GET|HEAD | agents/{id} | agents.show | App\Http\Controllers\PagesController@agentshow | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | blog | blog | App\Http\Controllers\PagesController@blog | web |
| | GET|HEAD | blog/author/{username} | blog.author | App\Http\Controllers\PagesController@blogAuthor | web |
| | GET|HEAD | blog/categories/{slug} | blog.categories | App\Http\Controllers\PagesController@blogCategories | web |
| | POST | blog/comment/{id} | blog.comment | App\Http\Controllers\PagesController@blogComments | web |
| | GET|HEAD | blog/tags/{slug} | blog.tags | App\Http\Controllers\PagesController@blogTags | web |
| | GET|HEAD | blog/{id} | blog.show | App\Http\Controllers\PagesController@blogshow | web |
| | POST | contact | contact.message | App\Http\Controllers\PagesController@messageContact | web |
| | GET|HEAD | contact | contact | App\Http\Controllers\PagesController@contact | web |
| | GET|HEAD | gallery | gallery | App\Http\Controllers\PagesController@gallery | web |
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\LoginController@login | web,guest |
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
| | GET|HEAD | property | property | App\Http\Controllers\PagesController@properties | web |
| | GET|HEAD | property/city/{cityslug} | property.city | App\Http\Controllers\PagesController@propertyCities | web |
| | POST | property/comment/{id} | property.comment | App\Http\Controllers\PagesController@propertyComments | web |
| | POST | property/message | property.message | App\Http\Controllers\PagesController@messageAgent | web |
| | POST | property/rating | property.rating | App\Http\Controllers\PagesController@propertyRating | web |
| | GET|HEAD | property/{id} | property.show | App\Http\Controllers\PagesController@propertieshow | web |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest |
| | GET|HEAD | search | search | App\Http\Controllers\FrontpageController@search | web |
| | GET|HEAD | slider | slider.index | App\Http\Controllers\FrontpageController@slider | web |
| | POST | user/changepassword | user.changepassword.update | App\Http\Controllers\User\DashboardController@changePasswordUpdate | web,auth,user |
| | GET|HEAD | user/changepassword | user.changepassword | App\Http\Controllers\User\DashboardController@changePassword | web,auth,user |
| | GET|HEAD | user/dashboard | user.dashboard | App\Http\Controllers\User\DashboardController@index | web,auth,user |
| | GET|HEAD | user/message | user.message | App\Http\Controllers\User\DashboardController@message | web,auth,user |
| | DELETE | user/message/delete/{id} | user.messages.destroy | App\Http\Controllers\User\DashboardController@messageDelete | web,auth,user |
| | GET|HEAD | user/message/read/{id} | user.message.read | App\Http\Controllers\User\DashboardController@messageRead | web,auth,user |
| | POST | user/message/readunread | user.message.readunread | App\Http\Controllers\User\DashboardController@messageReadUnread | web,auth,user |
| | POST | user/message/replay | user.message.send | App\Http\Controllers\User\DashboardController@messageSend | web,auth,user |
| | GET|HEAD | user/message/replay/{id} | user.message.replay | App\Http\Controllers\User\DashboardController@messageReplay | web,auth,user |
| | POST | user/profile | user.profile.update | App\Http\Controllers\User\DashboardController@profileUpdate | web,auth,user |
| | GET|HEAD | user/profile | user.profile | App\Http\Controllers\User\DashboardController@profile | web,auth,user |
+--------+-----------+---------------------------------------+-----------------------------+------------------------------------------------------------------------+----------------+
by Ticketa » Thu Oct 15, 2020 10:17 am
Открих проблема

public function store(Slider $request

Става на

public function store(Request $request

Edit; сега видях на колегата над мен мнението. Модела съм го публикувал по горе.
Go to full post

User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Ticketa » Thu Oct 15, 2020 7:19 am

Дори след като добавих функцията show(Slider $id) в контролера продължавам да имам проблеми.

"Method Illuminate\Database\Query\Builder::validate does not exist."

Code: Select all

public function show($id)
    {
        
        //print_r($id);
        //
        
        $slider = Slider::find($id);
        //$slider = Slider::withCount('sliders')->find($post->id);

        return view('admin.sliders.show', compact('slider'));
    }
А това ми е модела;

Code: Select all

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Slider extends Model
{
    protected $fillable = ['title','description','image'];
}

User avatar
dakata__92
Web-tourist
Web-tourist
Posts: 3332
Joined: Tue Aug 02, 2011 7:24 pm
Answers: 127

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by dakata__92 » Thu Oct 15, 2020 7:52 am

Прилича ми на проблем с namespace. Където ползваш Slider му подай пълния път: \App\Http\Controllers\Admin\Slider а в рутера подай също namespace:

Code: Select all

Route::group(['namespace' => 'Admin'], function()
{
   Route::resource('sliders','SliderController');
});
или

Code: Select all

Route::resource('sliders','\Admin\SliderController');
Смятам, че проблема ти е в това, че стандартно се приема App\Http\Controllers а ти вътре имаш папка Admin с namespace навътре с 1 ниво. Тоест трябва да укажеш пътя до контролера. Поне това смятам, че е в момента.

Fakeheal
Гуру
Гуру
Posts: 2715
Joined: Sat Apr 17, 2010 6:37 am
Answers: 351
Location: /r/eyebleach
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Fakeheal » Thu Oct 15, 2020 9:09 am

Може да използваш:

Code: Select all

php artisan route:cache
за да кешираш наново routing-a.

User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Ticketa » Thu Oct 15, 2020 9:35 am

Връща следната грешка след като направих промените , иначе пътя е същият.

["Class App\Http\Controllers\Admin\Slider does not exist"

User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Ticketa » Thu Oct 15, 2020 9:41 am

Замислих се ... Дали пък не търсим на грешното място проблема? Дали проблема не е в самата функция store или в самия модел , който по горе публикувах ?

Edit:
Опитах като игнорирам валидацията на полетата , сега пък дава следната грешка

"Method Illuminate\Database\Query\Builder::file does not exist."

Сложих и функцията за forceCreate но отново е тази грешка
"Method Illuminate\Database\Query\Builder::file does not exist."

Code: Select all

public function store(Slider $request)
    {
        /*$request->validate([
            'title' => 'required|unique:sliders|max:255',
            'image' => 'required|mimes:jpeg,jpg,png'
        ]);
*/
        $image = $request->file('image');
        $slug  = str_slug($request->title);

        if(isset($image)){
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();

            if(!Storage::disk('public')->exists('slider')){
                Storage::disk('public')->makeDirectory('slider');
            }
            $slider = Image::make($image)->resize(1600, 480)->save();
            Storage::disk('public')->put('slider/'.$imagename, $slider);
        }else{
            $imagename = 'default.png';
        }

        $slider = new Slider();
        
        $slider->forceCreate(request()->only([
        'title', 'description', 'imagename',]));
        
        
        //$slider->title = $request->title;
       // $slider->description = $request->description;
      //  $slider->image = $imagename;
        $slider->save();

        Toastr::success('message', 'Slider created successfully.');
        return redirect()->route('admin.sliders.index');
    }

mapka7a
Турист
Турист
Posts: 249
Joined: Mon Sep 05, 2011 9:21 am
Answers: 20
Location: Sofia
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by mapka7a » Thu Oct 15, 2020 10:05 am

Надявам се това Slider $request да е FormRequest
Дали не е нещо от аутолоудинга - composer dump-autoload
Някъде пасваш file функция на билдер, което не е окей. Може ли да видим и модела ?

User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by Ticketa » Thu Oct 15, 2020 10:17 am

Открих проблема

public function store(Slider $request

Става на

public function store(Request $request

Edit; сега видях на колегата над мен мнението. Модела съм го публикувал по горе.

mapka7a
Турист
Турист
Posts: 249
Joined: Mon Sep 05, 2011 9:21 am
Answers: 20
Location: Sofia
Contact:

Re: Laravel - BadMethodCallException Method App\Http\Controllers\Admin\SliderController::show does not exist.

Post by mapka7a » Thu Oct 15, 2020 10:29 am

Ticketa wrote:
Thu Oct 15, 2020 10:17 am
Открих проблема

public function store(Slider $request

Става на

public function store(Request $request

Edit; сега видях на колегата над мен мнението. Модела съм го публикувал по горе.
По-скоро помислих ако има и някъв друг, който да го наследява/екстендва...
Важното е че си го оправил, пък ако искаш custom request validator - Laravel Reuqests Validation

Post Reply