dimanche 17 avril 2016

retreaving data from database using laravel

I would like someone to help me step by step laravel process in retrieving data from databse. This is what I have done. The problem is no data is being displayed. I am not so good in this and need some help.Thanks

ViewController.php

<?php
namespace App\Http\Controllers\AddressBook;
use DB;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Redirect;

class ViewController extends Controller
{
    /**
     * Show a list of all of the application's users.
     *
     * 
     */
      Public function getContacts(){

        $contacts= AddressBookModel::all();

        $data = ['contacts' => $contacts];

        return view('view')->with($data);

        }

}
**Route**
Route::get('contacts',[
    'uses'=>'AddressBook\ViewController@getContacts'
]);
The Route is working well and its connecting and display the content in view.blade.php

**view.blade.php**
<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>



    </head>
    <body>
        <h2 align="center">These are the Registered Contacts in the Database</h2>
    </body>

</html>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire