/** * Store a newly created resource in storage. * * @return Response */ public function store() { $logbook = new Logbook(); $logbook->unguard(); $logbook->fill(Input::only('title', 'user_id', 'in_overview')); if ($logbook->validate()) { $logbook->save(); } else { return View::make('logbooks.create', ['logbook' => $logbook])->withErrors($logbook->validator()); } return Redirect::to(route('logbooks.index')); }
public function run() { $general = new Logbook(['title' => 'Algemeen logboek', 'user_id' => 1]); $general->save(); // Create a personal logbook for every user foreach (User::all() as $user) { if (substr($user->email, 0, 6) === 'system') { continue; } $name = ucfirst($user->username); $logbook = new Logbook(['title' => "{$name}'s logboek", 'user_id' => $user->id]); $logbook->save(); } }
public function postSave() { $input = array('title' => Input::get('title'), 'description' => Input::get('description'), 'prioritiy' => Input::get('priority')); $rules = array('title' => 'required', 'description' => 'required'); $messages = array('title.required' => 'Judulnya yang benar', 'description.required' => 'Deskripsi yang benar', 'priority.required' => 'Pilih salah satu prioritas'); $validation = Validator::make($input, $rules, $messages); if ($validation->fails()) { return Redirect::back()->withErrors($validation)->withInput(); } else { $logbook = new Logbook(); $logbook->user_id = Sentry::getUser()->id; $logbook->title = Input::get('title'); $logbook->deskripsi = Input::get('description'); $logbook->priorities_id = Input::get('priority'); $logbook->save(); return Redirect::back()->with('successMessage', "New Event was Added to Logbook's Record"); } }