Laravel membuat pengontrol
php artisan make:controller MyController
Eranot
php artisan make:controller MyController
public function store(PersonalInfoRequest $request)
{
// 1.validation
try {
// except csrf token from form
$data = request()->except(['_token']);
// convert lower case value to upper case from array
$check = array_map('strtoupper', $data);
// insert all upper case value once in DB
$value = PersonalInformationModel::Insert($check);
DB::commit();
if($value){
$this->JsonData['status'] = 'success';
$this->JsonData['url'] = route('reservation.index');
$this->JsonData['msg'] = 'Succesfully stored Personal details';
}
}
catch(\Exception $e) {
$this->JsonData['msg'] = 'Something wen`t wrong on server! Please try again';
$this->JsonData['status'] = $e->getMessage();
DB::rollback();
}
return response()->json($this->JsonData);
}
php artisan make:controller ControllerName
php artisan make:controller MyController
php artisan make:controller CompanyController --resource
//To create with a Model
php artisan make:controller CompanyController --resource --model=CompanyModel
php artisan make:controller PhotoController --resource --model=Photo
php artisan make:controller FormIndexController