model = $demo_restaurant; $function = Str::camel($action); event('litecms.demo.demo_restaurant.action.' . $action . 'ing', [$demo_restaurant]); $data = $this->$function($demo_restaurant, $request); event('litecms.demo.demo_restaurant.action.' . $action . 'ed', [$demo_restaurant]); $this->logsAction(); $this->notify(); return $data; } public function store(DemoRestaurant $demo_restaurant, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $demo_restaurant = $demo_restaurant->create($attributes); return $demo_restaurant; } public function update(DemoRestaurant $demo_restaurant, array $request) { $attributes = $request; $demo_restaurant->update($attributes); return $demo_restaurant; } public function destroy(DemoRestaurant $demo_restaurant, array $request) { $demo_restaurant->delete(); return $demo_restaurant; } public function copy(DemoRestaurant $demo_restaurant, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $demo_restaurant = $demo_restaurant->replicate(); $demo_restaurant->created_at = Carbon::now(); $demo_restaurant->save(); return $demo_restaurant; } for ($i = 1; $i <= $count; $i++) { $new = $demo_restaurant->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $demo_restaurant; } }