How to use roles in a Laravel package - laravel-5

I'd like to have roles in a package I'm creating. What is the best way to do this?
Should I use an existing package (Entrust, Bouncer, etc.) or should I implement a roles feature with no dependency?
Using an existing package could end in a conflict if it's already installed in another version, or if another package is already used.
Implementing the feature with no dependency is like reinventing the wheel...

Actually, the best approch is probably to not define roles or implement authorization of any kind in the package and let the user define policies in their application.
Default policies may be provided and published with artisan vendor:publish command, if the user wants to.
Models should use Gate to check user's ability to view/create/delete/etc.

Related

Question: It's possible to use Angular version without authorization?

I want to use Abp as base for my company projects, actually we use Oracle for Database.
The problem is all bussiness logic including Users, Roles are managed by the database, in my case I don't need to use authorization.
Really I need a clean version of the framework wihout any table. I know I can download the framework like this If I don't mark the check "Include login, register, user, role and tenant management pages." but this template is for MVC and I need something like this but for Angular.
My question is
Is there any way I can get the framework like this for angular?
Any way to clean It and how can I do it?
I hope you can help me, I will appreciate it.
If you unslect Include login, register, user, role and tenant management pages, it does not include most of them and gives you a clean project. Did you check that?

Can Laravel generate all mvc skeleton out of an existing table like that of cakephp's command cake bake all

I found laravel very interesting. But I'm wondering if there's any artisan command to generate all MVC skeleton files provided a database table all at ones. And how about separate generation of especially the model, given the table structure? or is there any alternative way to do the code generating?
You can create a migration file from the table via the package below.
https://github.com/Xethron/migrations-generator
Install it via : composer require --dev "xethron/migrations-generator"
Follow the package instructions, After connecting you application with the database simply run php artisan migrate:generate.
You will see number of migrations created via console message, You can also check your database/migrations folder for confirmation.
I didn't find how to do that, so I created my own code in order to create the models:
https://github.com/Triun/laravel-model-base
It is not super documented, but you can actually write your own addons in order to add custom business behaviors or include your own interfaces or traits to your models, with your own code.
And of course, reports and contributions are more than welcome.
I hope this helps.

Check config/assets are published or not in Laravel package

I have two questions which are quite related.
1) I'm building a Laravel package which will have a package config file. It can be published using php artisan vendor:publish command. Now in the service provider class of that package, I want to know that if that file has been published by the user or not. How can I do that? By simply checking file existence or is there any Laravel specific way for that?
2) In the view file of that package, I want to include a js file which is also there in that same package. How can I do that? Do I have to publish it first into Laravel's public directory and then include it? If possible I don't want to publish it.
Let me know if anything is not clear.
Thanks

Best practice for adding captcha to user registration

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.

how to use laravel illuminate in a custom project

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/

Resources