Laravel

Command line tool to debug / play with data

php artisan tinker
<li class="nav-item{{ $activePage == 'map' ? ' active' : '' }}">
  <a class="nav-link" href="{{ route('map') }}">
    <i class="material-icons">location_ons</i>
      <p>{{ __('Maps') }}</p></a>
</li>

route('map') needs to be matched by a route which has a name 'map' as in this example https://laravel.com/docs/master/routing#named-routes

Route::get('map', function () {
	return view('pages.map');
})->name('map');

Reference: https://stackoverflow.com/questions/23505875/laravel-routeresource-vs-routecontroller

Route::resource('users', 'UsersController');

Gives you these named routes:

Verb          Path                        Action  Route Name
GET           /users                      index   users.index
GET           /users/create               create  users.create
POST          /users                      store   users.store
GET           /users/{user}               show    users.show
GET           /users/{user}/edit          edit    users.edit
PUT|PATCH     /users/{user}               update  users.update
DELETE        /users/{user}               destroy users.destroy

Routes → Controllers → Requests (defines variables - from app/table)

MAP

Return all data from column X

App\Project::all()->map->title;

Document Later!

$report->linecollections()->attach(1);
$report->linecollections()->sync(2);
$report->linecollections()->sync([2,3]);
 
 if (null === $var->where('id',5)) echo 'blah'
 if (null !== $var->where('id',5)) echo 'blah'
 
>>> $myvar = $linecollectionsUnassigned->where('id',5)->first();
=> {#3064
     +"id": "5",
     +"name": "Dentist1",
     +"description": "Dentist SG                                                                                                                                                                                                                                                     ",
     +"created_at": "2019-11-14 17:08:34.303",
     +"updated_at": "2019-11-15 18:17:19.117",
   }
>>> $myvar->id
=> "5"
>>>
php artisan route:list
+--------+-----------+---------------------------------------+-------------------------+------------------------------------------------------------------------+--------------+
| Domain | Method    | URI                                   | Name                    | Action                                                                 | Middleware   |
+--------+-----------+---------------------------------------+-------------------------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                     |                         | Closure                                                                | web          |
|        | GET|HEAD  | api/user                              |                         | Closure                                                                | api,auth:api |
|        | GET|HEAD  | dualllistbox                          | duallistbox.edit        | App\Http\Controllers\DualListBoxController@edit                        | web,auth     |
|        | PUT       | dualllistbox                          | duallistbox.update      | App\Http\Controllers\DualListBoxController@update                      | web,auth     |
|        | GET|HEAD  | home                                  | home                    | App\Http\Controllers\HomeController@index                              | web,auth     |
|        | GET|HEAD  | linecollections                       | linecollections.index   | App\Http\Controllers\LinecollectionController@index                    | web,auth     |
|        | POST      | linecollections                       | linecollections.store   | App\Http\Controllers\LinecollectionController@store                    | web,auth     |
|        | GET|HEAD  | linecollections/create                | linecollections.create  | App\Http\Controllers\LinecollectionController@create                   | web,auth     |
|        | DELETE    | linecollections/{linecollection}      | linecollections.destroy | App\Http\Controllers\LinecollectionController@destroy                  | web,auth     |
|        | PUT|PATCH | linecollections/{linecollection}      | linecollections.update  | App\Http\Controllers\LinecollectionController@update                   | web,auth     |
|        | GET|HEAD  | linecollections/{linecollection}/edit | linecollections.edit    | App\Http\Controllers\LinecollectionController@edit                     | web,auth     |
|        | GET|HEAD  | login                                 | login                   | App\Http\Controllers\Auth\LoginController@showLoginForm                | web,guest    |
|        | POST      | login                                 |                         | App\Http\Controllers\Auth\LoginController@login                        | web,guest    |
|        | POST      | logout                                | logout                  | App\Http\Controllers\Auth\LoginController@logout                       | web          |
|        | GET|HEAD  | password/confirm                      | password.confirm        | App\Http\Controllers\Auth\ConfirmPasswordController@showConfirmForm    | web,auth     |
|        | POST      | password/confirm                      |                         | App\Http\Controllers\Auth\ConfirmPasswordController@confirm            | web,auth     |
|        | POST      | password/email                        | password.email          | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web          |
|        | GET|HEAD  | password/reset                        | password.request        | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web          |
|        | POST      | password/reset                        | password.update         | App\Http\Controllers\Auth\ResetPasswordController@reset                | web          |
|        | GET|HEAD  | password/reset/{token}                | password.reset          | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web          |
|        | PUT       | profile                               | profile.update          | App\Http\Controllers\ProfileController@update                          | web,auth     |
|        | GET|HEAD  | profile                               | profile.edit            | App\Http\Controllers\ProfileController@edit                            | web,auth     |
|        | PUT       | profile/password                      | profile.password        | App\Http\Controllers\ProfileController@password                        | web,auth     |
|        | GET|HEAD  | register                              | register                | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web,guest    |
|        | POST      | register                              |                         | App\Http\Controllers\Auth\RegisterController@register                  | web,guest    |
|        | GET|HEAD  | reports                               | reports.index           | App\Http\Controllers\ReportController@index                            | web,auth     |
|        | POST      | reports                               | reports.store           | App\Http\Controllers\ReportController@store                            | web,auth     |
|        | GET|HEAD  | reports/create                        | reports.create          | App\Http\Controllers\ReportController@create                           | web,auth     |
|        | PUT|PATCH | reports/{report}                      | reports.update          | App\Http\Controllers\ReportController@update                           | web,auth     |
|        | DELETE    | reports/{report}                      | reports.destroy         | App\Http\Controllers\ReportController@destroy                          | web,auth     |
|        | PUT       | reports/{report}/edit                 | reports.edit            | App\Http\Controllers\ReportController@editcollection                   | web,auth     |
|        | GET|HEAD  | reports/{report}/edit                 | reports.edit            | App\Http\Controllers\ReportController@edit                             | web,auth     |
|        | POST      | user                                  | user.store              | App\Http\Controllers\UserController@store                              | web,auth     |
|        | GET|HEAD  | user                                  | user.index              | App\Http\Controllers\UserController@index                              | web,auth     |
|        | GET|HEAD  | user/create                           | user.create             | App\Http\Controllers\UserController@create                             | web,auth     |
|        | PUT|PATCH | user/{user}                           | user.update             | App\Http\Controllers\UserController@update                             | web,auth     |
|        | DELETE    | user/{user}                           | user.destroy            | App\Http\Controllers\UserController@destroy                            | web,auth     |
|        | GET|HEAD  | user/{user}/edit                      | user.edit               | App\Http\Controllers\UserController@edit                               | web,auth     |
+--------+-----------+---------------------------------------+-------------------------+------------------------------------------------------------------------+--------------+
 php artisan scout:import "App\Enduser" 
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies