Laravel CRUD: Fetch & Display Data using Resource Controller with Eloquent Model | CRUD in Laravel

preview_player
Показать описание
The CRUD operation in Laravel can be performed either by Basic Controllers or by Resource Controllers. In this video, Fetch or Read operation of the CRUD has been shown with the help of Resource Controllers.

**************************************************

Links to the important videos mentioned below-

=== Understanding the basic of Resource Controllers and Routing Conventions ===

=== Fetching data using Basic Controller ===

=== Inserting Data using Forms ===

=== Creating table using migrations ===

== Connecting MySQL with Laravel ===

***************************************************
The commands used in this video are-

1. Create a resource Controller:
php artisan make:controller --resource productController

2. Create a resource Controller with model embedded into it:
php artisan make:controller --resource productController -m Product

3.To Display all the routes in the project:
php artisan route:list

#laravel #ResourceControllers
Рекомендации по теме
Комментарии
Автор

Madam, i want to set a column name (p_id) instead of (id) what to do?

saranrajn
Автор

Could you help me out, please!
I have TWO TABLES with relationship.
In my index method, I join them and compact the $real .
$real = DB::table('declarers')
->join ('estates', 'declarers.id', 'estates.item_id')
->get();

In my index view, I loop through the $real: @foreach ($real as $pr) and manage to display the data.

However, problem occurs with the Show button <a class="btn btn-info" href="{{ route('products.show', $pr->id) }}">Show</a>
As, this takes the ID of ONE TABLE only (the estates table).
And thus, in show method +show view, I can only display the information from the estates table.
What should I do to display the corresponding information from the declarers too?

I am looking forward to your advice, and thank you in advance!

gamnguyen
Автор

mam in my case when the show function is running, id is displayed on the URL when I m writing /studentresource/{{$n->id}} in the href, also the show function is being called (I have checked by returning a simple text ) but when I m returning the parameter I.e Student $student as return $student, it is displaying an empty array.

niharikasharma
join shbcf.ru