/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { if (isset(\Auth::user()->site_id)) { $sites_ids = SiteLanguages::site_access()->select(\DB::raw(' GROUP_CONCAT(id) as sites_ids'))->groupBy('sites_id')->get(); $site_access = 'in:' . $sites_ids[0]->sites_ids; } else { $site_access = ''; } return ['sitelanguages_id' => 'required|' . $site_access, 'title' => 'required|unique:topmenus,title,' . $this->topmenus, 'link' => 'required']; }
public static function boot() { parent::boot(); SiteLanguages::observe(new UserActionsObserver()); }
/** * Mass delete function from index page * @param Request $request * * @return mixed */ public function massDelete(Request $request) { if ($request->get('toDelete') != 'mass') { $toDelete = json_decode($request->get('toDelete')); SiteLanguages::destroy($toDelete); } else { SiteLanguages::whereNotNull('id')->delete(); } return redirect()->route('admin.sitelanguages.index'); }