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