Skip to content

Instantly share code, notes, and snippets.

@sab99r
Last active May 25, 2020 09:23
Show Gist options
  • Save sab99r/05138f87b71f43dad76e39f900185399 to your computer and use it in GitHub Desktop.
Save sab99r/05138f87b71f43dad76e39f900185399 to your computer and use it in GitHub Desktop.
[Laravel Notes] #laravel

Laravel Notes

Router

Route::get('/posts/{postId}',function($postId){
  //Request Params
  $param = request('param');
  return view('post',['id' => $postId]);
});

/*In Controller show function receive url and request params 
as received in above route function*/
Route::get('/posts/{postId}','PostController@show');

Layout Extending (PHP Include Alternate with more features)

//layout.blade.php (Layout Skeleton)
<html>
@yeald('content')
<html>
  
//post.blade.php
@extends('layout')
@section('content')
  <h1>Post Title</h1>
@endContent

Get / Check Current Path

Request::path(); // get path after root domain
Request::is('post'); //Check path 

Implement third party using mix

Fix Common Erros

1. Error Caused By MySQL 8.0 Default auth plugin auth_socket
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password
BY 'password';  

StackOverflow

2. PHP Zip Plugin Missing Error (macOS)
1. brew install php (latest one)
2. brew link php@version_number (Else later cause Laravel Valet install error)
3. add php new path
4. check path updated with the latest installed php (command: which php)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment