> For the complete documentation index, see [llms.txt](https://charliepage.gitbook.io/book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://charliepage.gitbook.io/book/laravel.md).

# Laravel

#### Permissions for Cache

```
sudo find storage/ -type f -exec chmod 664 {} \;
sudo find storage/ -type d -exec chmod 775 {} \;
sudo find bootstrap/cache/ -type f -exec chmod 664 {} \;
sudo find bootstrap/cache/ -type d -exec chmod 775 {} \;

sudo chown -R charlie:www-data storage
sudo chown -R charlie:www-data bootstrap/cache

sudo chmod -R ug+w storage
sudo chmod -R ug+w bootstrap/cache

sudo chmod g+s storage
sudo chmod g+s bootstrap/cache

php artisan cache:clear

composer dump-autoload
```

**Other Option (might be best to combine)**

```
setfacl -R -dm u:www-data:rwx storage
setfacl -R -m u:www-data:rwx storage
chmod -R g+w storage
```

#### Use below if you want identifier other than ID to be used with routing. (passing in User $user in a controller for example)

```php
Route::bind('slug', function ($slug) {
    return Pattern::whereSlug($slug)->firstOrFail();
});
```

#### With Notifications, class name CANNOT end in Notification. For example, ResetPasswordNotification (as of Laravel 5.4) will have issues when passing in objects via the constructor of the notification class.

### Retry failed jobs

Replace 100 & 150 with the first ID of a failed job & the last ID of a failed job. (see php artisan queue:failed)

```
for ($i = 100; $i <= 150; $i ++) Artisan::call('queue:retry', ['id' => $i]);
```

#### Create Model with Migration

```
php artisan make:model Notes -m
```
