action = $action; $this->request = $request; $this->model = $college; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(College $college, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $college = $college->create($attributes); return $college; } public function update(College $college, array $request) { $attributes = $request; $college->update($attributes); return $college; } public function destroy(College $college, array $request) { $college->delete(); return $college; } public function copy(College $college, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $college = $college->replicate(); $college->created_at = Carbon::now(); $college->save(); return $college; } for ($i = 1; $i <= $count; $i++) { $new = $college->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $college; } }