Last active
November 9, 2021 09:11
-
-
Save vishnusomanus/da9091a8c4c67039423af194920e1bd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composer require laravel/ui | |
php artisan ui bootstrap | |
php artisan ui bootstrap --auth | |
npm install && npm run dev | |
php artisan key:generate | |
//resource controller | |
php artisan make:controller PhotoController --resource --model=Photo | |
//store | |
public function store(Request $request) | |
{ | |
$rules = array( | |
'name' => 'required', | |
'c_or_e' => "required|in:civil,electrical", | |
'status' => "required|in:open,substantially,complete,closed", | |
'invoiced_date' => "date_format:Y-m-d", | |
'start_date' => "date_format:Y-m-d", | |
'end_date' => "date_format:Y-m-d", | |
'cost_to_date' => "date_format:Y-m-d", | |
'contact_amount' => "numeric", | |
); | |
$customMessages = [ | |
'date_format' => 'The :attribute does not match the format '.date('Y-m-d').'.' | |
]; | |
$validator = Validator::make($request->all(), $rules, $customMessages); | |
if ($validator->fails()) { | |
return redirect('contracts/create') | |
->withErrors($validator) | |
->withInput( | |
$request->except('password') | |
); | |
} else { | |
$contract = new Contracts; | |
//$contract->name = $request->all()['name']; | |
$insert = array_except($request->all(), ['_token','submit']); | |
$contract->fill($insert); | |
$contract->save(); | |
return redirect('contracts/create')->with('success','Successfully created contract!'); | |
} | |
} | |
Route::get('/clear-cache', function() { | |
$exitCode = Artisan::call('cache:clear'); | |
return "Cache is cleared"; | |
}); | |
Route::match(['get', 'post'], '/ajax/{method}', function () { | |
$method = Route::current()->method; | |
return App::call('App\Http\Controllers\AjaxController@' . $method); | |
})->name('ajax'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment