How to show data as per users in Voyager Laravel - laravel-5

Voyager is one of the most efficient admin panel for laravel. But, here I am trapped in a typical situation. For example, I am using this admin panel for booking appointment. I want the admin to view all the records but the user to view, edit, delete only the records which he had added. I can insert my own Page there but that will increase the work as I have to create my own add, edit, and delete functionality along with the view. I just want to know the place where the data is fetched from database to display on the view page so that as per the login user I could manipulate it.

To achieve this:
You need to add policy to your bread php artisan make:policy PostPolicy
Inside the policy you can specify who can edit what depending on your logic

Related

Creating admins table separate in Laravel 8

I am creating a Laravel project for the users. Laravel has its own laravel/ui package, but I am creating its admin panel too, and I am a bit confused about what I should do for admins. Also, I am confused about the security for the admin panel. So there are 2 solutions in my mind:
Add a new column in the user's table named status, and if its value is admin, he can access the admin panel; otherwise, redirect to the homepage.
Create a separate admins table and improve laravel/ui auth. For that, I found documentation here.
What should I do? Even i have added table prefix for tables in .env & config/database.php. I am afraid that the hackers/users should not access the admin panel. And also, tell me if the table prefix is good for security, or should I remove the table prefix?
You need the permission-roles system.
https://spatie.be/docs/laravel-permission/v4/introduction
This is good decision for you. With well-configured routes no one wont have access in admin panel without access in data base.
For example, in panel page only admin have access:
Route::name('adminspace.')->group(['middleware' => ['role:admin']], function () {
Route::view('/panel', 'pages.panel');
});

Add link in user drop down menu using Laravel

When a user is logged in they see the standard drop down menu in the top right (which is created by Laravel). I'd like to create a "Settings" page where logged in users can go to edit their personal info, upload profile photos etc.
I can't figure out how to add a link to the users drop down menu in the top right?
I've tried adding a link in web.php
Route::get('/settings', 'HomeController#settings')->name('settings');
I'm new to Laravel so am probably missing something obvious!
The default Laravel authentication uses the layout at resources/views/layouts/app.blade.php which you can see in the first line of the auth views (e.g. resources/views/auth/login.blade.php):
#extends('layouts.app')
Note that the dropdown entries are different for guests and logged-in users using #guest, #else and #endguest.
For the styling you can refer to the Bootstrap Navbar docs.

How to save contact us form data in magento2

I am new to Magento 2. Can any one tell me how to save contact us form data into the database using events and observers, and display them in admin grid under the customer section in Magento 2?
If you have set SMPT to your magento2 store then you will receive conatct us data to mail id which you mention at Stores->Configuration->General->Contacts->Email Option->Send Emails to.
On this if you wish to show at admin grid, you must create your own table and grid to show the data in admin and create a before plugin to the controller Magento\Contact\Controller\Index\Post where you save data into your table you created.
You must create a separate module for the contact us a table, admin grid and forms.

Magento Customer Wizard Registration

I'm trying to create a simple registration for the magento visitors using custom steps. I need to create a wizard that helps the users to follow a path previously set in the administration panel.
At the moment I have created the extension but I am having some difficulties to create the front-end wizard form. What I'd like to achieve is a multi registration form where if the user go from the first form to the second one Magento has to save the data and wait if the user wants to go on the next new form and so on...
Here a mockup: http://minus.com/lF3krBVJG0WEM
How have I to create a multiform that follow this behaviour?
Regards

Redirect Magento user to different store view checkout / product page based on product attribute

Is there a way to force a switch to a different store view in Magento when a user clicks on checkout or the product page?
To clarify the issue, let's presume we have 2 different store views in Magento:
One main store view (View A) that all users go to upon arriving to the store. This view displays products that are set to appear in all store views in the system
One customized store view (View B) that has some specific branding and some other specific settings related to checkout, payment gateways etc.
When the user is browsing products in View A and clicks on either the checkout link or the product page link, we want to redirect them to View B and let them proceed with the checkout in that View.
Is this possible to accomplish in a relatively easy manner, and how?
Thanks.
In Magento each store is assigned an interface. An interface can have multiple themes in it. This is what I understand by what you call a View. Your templates can refer to theme1/css or theme2/css to give you different looking View A and View B.
To create a different looking checkout page you will have to code app/design/frontend/myinterface/default/template/checkout/onepage.phtml or whatever to use the appropriate theme1/css or theme2/css to change its look.
If however you are using different interfaces then they can only be assigned to different stores. This would be a multi-store setup. In which case you can change the Checkout button in View A (Store A) to link to View B (Store B). You will also have to write some code to allow automatic population of information for the order from Store A to be passed to Store B.
Add a new store config which will store the base url of the product listing store.
We want the user to land on the checkout site home page, that will be the main page and you can override:
/Catalog/Model/Product/Url.php
getProductUrl and getUrl functions
where you would simply string replace the returned parent::getUrl's base url value with the base value in your new config.
Therefore what will happen is when the user clicks on catalog navigation they will be taken to the other store. Finally when they again click back on checkout or any other link that will bring them back to the checkout store.

Resources