/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $validator = Validator::make($data = $request->all(), Contact::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $contact = Contact::all()->first(); $contact = $contact ? $contact : new Contact(); $contact->fill($data); $contact->save(); return Redirect::route('contact.index'); }
public function index(Contact $contact) { $contacts = $contact->all(); return view('contact.index')->with('contacts', $contacts); }
public function index() { $data = ['title' => 'Список контактов', 'view_all' => true, 'contacts' => Contact::all()->toArray()]; //dd($data); return view('templates.index', $data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // get a list of all contacts return view('contact.index', ['contacts' => \App\Models\Contact::all()]); }
<table class="table table-striped table-bordered table-hover" id="dataTables-example"> <thead> <tr> <th>Rendering engine</th> <th>Browser</th> <th>Platform(s)</th> <th>Engine version</th> <th>CSS grade</th> </tr> </thead> <tbody> <?php use App\Models\Contact; ?> <?php $contacts = Contact::all(); ?> <tr> <td><?php echo $contacts[0]->fullname; ?> </td> <td><?php echo $contacts[0]->address; ?> </td> <td><?php echo $contacts[0]->telephone; ?> </td> <td><?php
/** * Returns contacts.blade.php page * @return type view */ public function contacts() { $data = ['title' => 'Contacts', 'number' => Contact::find(1)->tel, 'contacts' => Contact::all()]; return view('pages.mainUserPages.contacts')->with($data); }
/** * Returns the page with all changable and deletable contacts * @return type view | Redirect * */ public function changeContacts() { if (Auth::check()) { $data = ['title' => 'Contacts list', 'contacts' => Contact::all()]; return view('pages.options.changeContacts')->with($data); } else { return Redirect::route('admin'); } }