/** * Create a new Enquiry. * * @param Request $request * @return Response */ public function store(Request $request) { $rules = array('user_id' => 'required|numeric', 'services' => 'required|numeric', 'subjectarea' => 'required|numeric'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return redirect('/ncf')->withErrors($validator)->withInput(); } else { // store $enquiry = new Enquiry(); $enquiry->userid()->user_id = $request->user_id; $enquiry->service_id = $request->services; $enquiry->sa_id = $request->subjectarea; $enquiry->save(); // redirect return redirect('/ncf'); } }
/** * Register any application authentication / authorization services. * * @param \Illuminate\Contracts\Auth\Access\Gate $gate * @return void */ public function boot(GateContract $gate) { $this->registerPolicies($gate); // role: super admin, manager, super agent, agent // page: dashboard, properties(villa, villa rental, land), enquiry, customer, blog, page, setting $gate->define('property-edit', function ($user, $property_id) { $user = $user->get(); $property = \App\Property::find($property_id); if ($user->role_id == 3 or $user->role_id == 4) { return $property->user_id == $user->id; } if ($user->role_id == 2) { return $property->user->branch_id == $user->branch_id; } if ($user->role_id == 1) { return true; } }); $gate->define('enquiry-edit', function ($user, $enquiry_id) { $user = $user->get(); $enquiry = \App\Enquiry::find($enquiry_id); if ($user->role_id == 3 or $user->role_id == 4) { return $enquiry->property->user_id == $user->id; } if ($user->role_id == 2) { return $enquiry->property->user->branch_id == $user->branch_id; } if ($user->role_id == 1) { return true; } }); $gate->define('customer-edit', function ($user, $customer_id) { $user = $user->get(); $customer = \App\Customer::find($customer_id); // if ($user->role_id == 3 OR $user->role_id == 4) return $customer->user_id == $user->id; // if ($user->role_id == 2) return $customer->user->branch_id == $user->branch_id; if ($user->role_id == 1) { return true; } }); $gate->define('user-edit', function ($user, $user_id) { $user = $user->get(); $account = \App\User::find($user_id); if ($user->role_id == 2) { return $account->branch_id == $user->branch_id; } if ($user->role_id == 1) { return true; } }); }
public function enquiries(Request $request, $term = null) { // if ($request->action == 'create') { return view('admin.pages.enquiry.create'); } if ($request->action == 'edit' && isset($request->id)) { if (Gate::denies('enquiry-edit', $request->id)) { return redirect()->back(); } $enquiry = \App\Enquiry::find($request->id); return view('admin.pages.enquiry.edit', compact('enquiry')); } $request = json_encode($request->all()); $request = json_decode($request, true); $api_url = route('api.enquiry.index', $request); return view('admin.pages.enquiry.listing', compact('api_url')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $enquiry = Enquiry::find($id); $enquiry->delete(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'object has been deleted'), 'id' => $id)); }
public function postEnquiry(Requests\EnquiryAddRequest $request) { $enquiry = new Enquiry(); $enquiry->email = $request->email; $enquiry->name = $request->name; $enquiry->enquiry = $request->enquiry; $enquiry->save(); $email = $enquiry->email; Mail::send('emails.messageThanks', ['name' => $enquiry->name], function ($message) use($email) { $message->from(Config::get('app.noreplyEmail'), Config::get('app.noreplyEmailName')); $message->to($email)->subject(Config::get('app.companyName') . ' - Message received'); }); Mail::send('emails.messageNotification', ['name' => $enquiry->name, 'email' => $enquiry->email, 'enquiry' => $enquiry->enquiry, 'id' => $enquiry->id], function ($message) { $message->from(Config::get('app.adminEmail'), Config::get('app.noreplyEmailName')); $message->to(Config::get('app.adminEmail'), Config::get('app.adminName'))->subject(Config::get('app.companyName') . ' - Message notification'); }); return Redirect::to('contact-us')->with('message', 'Thanks. Your message has been sent. You\'ll be hearing form us shortly')->with('type', 'success')->withInput(); }