*** php artisan config:cache
Other artisan commands
config:cache
cache:clear
views:clear
*** Migration
php artisan migrate
Rollback recent migration
php artisan migrate:rollback
* issue class not found
composer dump-auto
* Renaming migration classe
date_migration_name_date
Had problems when 2 migrations have differnt filename but same class
eg 2019_add_columns.php and 2018_add_columns.php
with classes AddColumns
Instead write migration as
2019_add_columns_2019.php with class name AddColumns2019
2018_add_columns_2018.php with class name AddColumns2018
*** Messagebag Object, used in validation errors;
class Illuminate\Support\MessageBag
$obj->add($key, $message)
//insert key later, maybe custom validation $key
//not array like syntax to set $obj[ $key ]
$obj->keys()
$obj->count();
$obj->isEmpty();
# Model
create/save will affect database
``` php
$trainee = Trainee::create(); //Maybe laravel create in db, with id; created_at, updated_at
$trainee = new Trainee; //This wont fill id from database
```
### To display all errors at once
```
@if($errors->any())
{!! implode('', $errors->all('
:message
')) !!}
@endif
```
### To display error under each field.
```
@error('firstname')
{{ $message }}
@enderror
```
$img_path=public_path('upload/users/'.$user_id. '/' .$filename);
if( is_file($img_path) ){
unlink($img_path);
}else{
echo "File does not exist";
}
?>