laravel-voyager custom views for role - laravel

Laravel Version: 5.26.27
Voyager Version: 1.1.3
PHP Version: 7.2.1
Database Driver & Version: MySQL 5.6.38
Description:
I'm new to Voyager but have already managed to create tables, populate them and configure their access privileges for BREAD.
But I need one option to see in the posts the custom roles can view just himself post, I see one option
#foreach($dataTypeContent->where('author_id','=', Auth::user()->id) as $data)
But this code modifies all views because is in the view. I need some more generic in the model
Is this possible with Voyager or it calls for custom code?
Thanks in advance!

Your question is a little confusing to read, but it sounds like you're asking if it's possible to override Voyager views or add custom views and the answer is, yes you can.
They have a video here: https://laravelvoyager.com/academy/views/
and written documentation here: https://voyager.readme.io/docs/overriding-views
The short of it is, create a directory resources/views/vendor/voyager/slug-name where slug-name is the slug for the corresponding table view you want to override. Put an edit-add.blade.php file in that folder along with a browse.blade.php file. I would just copy Voyagers default view logic into those files and then modify them to suit your needs.

Related

Getting CRUD data from laravel backpack to a new blade view page

I'm new to laravel backpack so what did is created a CRUD of title and description. And everything in admin panel works fine, but now I need to get that data to another blade view file through a controller like in a vanilla laravel but I cant seem to find how to do it.
If I understand your question correctly, there's absolutely NOTHING special you need to do - just do it "the normal Laravel way", by using your Model to query the database. It's usually something like Career::all() or Career::find($id) or Career::where('something', $value)->get(), depending on what you need to fetch from the database.
That's because Backpack uses your existing Eloquent Models, or creates the models if you don't have them already (usually in app\Models). So whenever you create/edit/delete an entry using the Backpack interface (aka CRUD), what Backpack does is use that Model to interact with the database. If you want to interact with the database, you should do the same thing - use the Model. That's the expected and recommended way of doing things in Laravel. To have Models for all your major database tables and do most (or all) of your interactions with the database using the Eloquent Models.
You can use view like this:
view('crud::show');
list, create etc.
all available files, you can find here: vendor/backpack/crud/src/resources/views/crud
If you want to override the template, please copy vendor template to your project
vendor/backpack/crud/src/resources/views/crud/show.blade.php > resources/views/vendor/backpack/crud/show.blade.php

Changing the author name In already built plugin in octobercms

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.

how to add or edit gravitar within laravel

I know that we can user the gravitar in laravel for display pic but how can we add one if the new user doesn't have it or wish to update the current one from within the application?
below article shows how to show existing gravitar in laravel.
How do I implement Gravatar in Laravel?
You can supply a default image through the Gravatar URL.
Documentation.

How to create a command to create a view in laravel version 5.8.23?

I want to create a command to create views by promp, I know it is possible, I saw examples in the laravel documentation but I could not understand :(

Where is the Registrar Services in Laravel 5?

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.

Resources