I'm using Laravel 5.1 with Bestmomo Scafold for user account management and I'm trying to add BotDetect captcha by following this quickstart tutorial. I was able to get it to work but to do so I had to modify the Illuminate\Foundation\Auth\RegistersUsers trait as opposed to the "ExampleController" that the tutorial uses.
I don't want to edit a vendor file, but I'm new to PHP so I'm wondering what alternative there is?
create a trait that extends from the one that you need, make the changes there and make your class uses the new trait and you will never touch vendor folder.
Related
I have designed a store with Laravel 6 ,and used laravel-permission 3 for user management. I'd like to restrict every crud action by a definite permission (e.g. add product, delete product).
There is a short description about using wildcard permission in Spatie, but I'm not sure about it. I don't know where is the best place in defining these restrictions.
Here is a route sample for creating and editing product and their middleware (restrictions by permissions).
Route::get('/create','Controller#create')->name('create')->middleware('permission:add product');
Route::post('/store', 'Controller#store')->name('store')->middleware('permission:add product');
Route::get('/{product}/edit', 'Controller#edit')->name('edit')->middleware('permission:edit product');
Route::patch('/{product}/update', 'Controller#update')->name('update')->middleware('permission:edit product');
I suggest that use Laravel’s Model Policies, you can find more information in the link below.
https://docs.spatie.be/laravel-permission/v3/best-practices/using-policies/
Furthermore, You can find an example of implementing a model policy with this Laravel Permissions package in this demo app:
https://github.com/drbyte/spatie-permissions-demo/blob/master/app/Policies/PostPolicy.php
I am building plugins that do simple CRUD in octobercms but the url in the backend has author name in it. I want to change it to something reliable to the website like max/home/home to page/home/home
Search for use max/home/home and replace with page/home/home inside model and controllers.
Rename the plugin folder with new author name.
You dont need to rebuild new tables, just make sure the models have proper table name.
On your theme, don't use builder to query results. Use the Models as done in laravel eloquent.
I'm using Laravel's out of the box authentication, which came with laravel 5.
Basically, my AuthController is empty, and all the logic happens within the AuthenticatesAndRegistersUsers trait.
Now I want to flash a message only after a user is registered.
I can change the trait, but it's not recommended, and might not work on future versions of Laravel.
There is a way to run my custom code from the Controller after user registers?
Just copy the trait into your controller, Laravel will use the method in your controller instead of the trait because it's kind of inheritance, that way you won't touch the trait and you will be sure that the method of the flash message will work on any version of Laravel
I added couple of fields to my user table and everywhere I read it said I also need to update the new fields in the app/Services/Registrar.php file. But I cannot find the Services folder anywhere! This is a new installation in Laravel 5 and here is the screen shot of my directory structure:
What happened to the Services Folder? When I test, I can see that the User::create() works but I dont know where its declared since I cant find the Registrar.php file.
I added couple of fields to my user table and everywhere I read it said I also need to update the new fields in the app/Services/Registrar.php file.
This was removed in Laravel 5.1.
https://laravel.com/docs/5.1/upgrade#upgrade-5.1.0
Secondly, the App\Services\Registrar class used in Laravel 5.0 is no longer needed. You can simply copy and paste your validator and create method from this class directly into your AuthController. No other changes should need to be made to these methods; however, you should be sure to import the Validator facade and your User model at the top of your AuthController.
You are using 5.1 version and it doesn't have such directory or service. This version uses AuthenticatesAndRegistersUsers traits for registering users.
I have a static site with a lot of pages. Now I got a new requirement. Client need a Client Area, I am thinking to use laravel Database Eloquent, Session, Form/html, Session and want to use them as alias like use in laravel/lumen. The problem is that I want static pages same as it is with .html extension, is there any solution? I want some packages with aliases to speed up.
I spent a complete day on Configuring Input and Eloquent but I wasn't able to setup to other packages. But I don't know how to set aliases and service providers. Any idea?
Specific:
I need Laravel Some packages
Session,
FileSystem
Mail
Input
Database
Html/Form,
Validation
I don't need others packages and need aliases same as laravel used in (config/app)
yes you can use laravel components outside laravel project please read the article : http://www.richardbagshaw.co.uk/using-illuminate-components/