/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (Gate::denies('manage-lists', $this->list)) { abort(403, 'You dont have permissions!!'); } return $this->list->create($request->all()); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('lists')->delete(); DB::table('todos')->delete(); $burimi = User::find(1); $kiqa = User::find(2); $drila = User::find(3); //new list $list = ListModel::create(['name' => 'Shopping List']); $list->collaborators()->attach($burimi); $list->collaborators()->attach($kiqa); $list->collaborators()->attach($drila); //new list $list = ListModel::create(['name' => 'Lessons']); //new list $list->collaborators()->attach($burimi); $list->collaborators()->attach($kiqa); $list->todos()->create(['name' => 'Upgrade server']); $list->todos()->create(['name' => 'Install patches', 'user_id' => $kiqa->id, 'deadline' => Carbon::now()]); $list->todos()->create(['name' => 'Remove old data', 'finished' => 1]); ListModel::create(['name' => 'Mix']); Model::reguard(); }