public function update(Client $client, ClientRequest $request) { //Client $client refrences a Route Model Binding method found is RouteServiceProvider.php $client->update($request->all()); \Session::flash('flash_message', 'Client ' . $client->first_name . ' ' . $client->last_name . ' was updated.'); return redirect('clients'); }
/** * Handle creation of new bill. * * @param CreateBillRequest $request * @return array */ public function create(CreateBillRequest $request) { // Save request data $clientName = $request->get('client'); $useCurrentCampaign = $request->get('use_current_campaign'); $campaignYear = $request->get('campaign_year'); $campaignNumber = $request->get('campaign_number'); $client = DB::table('clients')->where('name', $clientName)->where('user_id', Auth::user()->id)->first(); // Create new client if not exists if (!$client) { $client = new Client(); $client->user_id = Auth::user()->id; $client->name = $clientName; $client->save(); } // Create new bill $bill = new Bill(); $bill->client_id = $client->id; $bill->user_id = Auth::user()->id; $campaign = Campaigns::current(); // Check if current campaign should be used if (!$useCurrentCampaign) { $campaign = Campaign::where('year', $campaignYear)->where('number', $campaignNumber)->first(); } $bill->campaign_id = $campaign->id; $bill->campaign_order = Campaigns::autoDetermineOrderNumber($campaign, $client->id); $bill->save(); event(new UserCreatedNewBill(Auth::user()->id, $bill->id)); // Return response $response = new AjaxResponse(); $response->setSuccessMessage(trans('bills.bill_created')); return response($response->get()); }
public function submitOTP(Request $request) { //get mobile number from user input $mobileNum = $request->input('mobile'); //get user type from user input $userType = $request->input('userType'); //set user email $userEmail = '*****@*****.**'; //set country code $countryCode = 61; //initial authentication API // $authy_api = new AuthyApi(config('services.authy.key')); $authy_api = new AuthyApi(config('services.authy.key'), 'http://sandbox-api.authy.com'); //sandbox //register a user through email, cellphone, country_code $user = $authy_api->registerUser($userEmail, $mobileNum, $countryCode); //generate authentication token and send it to usser $sms = $authy_api->requestSms($user->id(), array("force" => "true")); if ($sms->ok()) { //check user exist or not $results = Client::where('mobile', $mobileNum)->first(); //if user does not exist, register of him if (empty($results)) { $newUser = new Client(); $newUser->mobile = $mobileNum; $newUser->save(); } return view('auth.otp')->with('userid', $user->id())->with('mobileNum', $mobileNum)->with('userType', $userType); } else { //session()->put('message','incorrect mobile number'); return redirect('login')->with('message', 'Please input correct mobile number'); } }
public function testClientSave() { $client = new Client(); $client->name = 'Idea7'; $client->country = 'IN'; $client->status = 'active'; if (!$client->save()) { $errors = $client->getErrors()->all(); echo 'Client Insert failed' . print_r($errors); $this->assertTrue(false); } else { $this->assertTrue(true); } }
public function destroy($id) { $client = Client::find($id); $client->delete(); $clients = Client::all(); return view('client.list')->with(['success' => 'Cliente excluído com sucesso!', 'clients' => $clients]); }
public function edit($id) { $access = Access::findOrFail($id); $client = Client::all()->lists('name', 'id'); $selected = array(); return view('access.edit', compact('access', 'client', 'selected')); }
public function handleAction(Request $request) { $action = $request->input('_action'); if ($action == 'createClient') { //Creation : Client::create($request->all()); // FLash messaging : flash()->success('Opération réussie!', 'Client créé avec succès.'); } else { if ($_POST['_action'] == 'getClientByID') { $id = $_POST['_uid']; $client = Client::where('id', $id)->with('files')->first(); return response(['status' => 'success', 'client' => $client], 200); } else { if ($_POST['_action'] == 'editClient') { $id = $_POST['id']; $client = Client::find($id); $client->lastname = $_POST['lastname']; $client->firstname = $_POST['firstname']; $client->email = $_POST['email']; $client->street = $_POST['street']; $client->postal_code = $_POST['postal_code']; $client->city = $_POST['city']; $client->vat = $_POST['tva']; $client->mobile = $_POST['mobile']; $client->office = $_POST['office']; $client->fax = $_POST['fax']; $client->save(); flash()->success('Opération réussie!', 'Client modifé avec succès.'); } else { } } } return redirect('/clients'); }
/** * Get the name of the user */ public function name() { if ($this->Type == 1) { return Worker::find($this->TypeId)->Name; } return Client::find($this->TypeId)->Name; }
/** * Display the specified resource. * * @param RentalAgreement $agreement * @return Response * @internal param int $id */ public function show(RentalAgreement $agreement) { $address = Address::find($agreement->property_id); $client = Client::find($agreement->client_id); $owner = Client::find($agreement->owner_id); return view('agreement.showAgreement', compact('agreement', 'address', 'client', 'owner')); }
static function clientsByName() { $clients = Client::orderBy('name')->get(['id', 'name'])->getDictionary(); return array_map(function ($client) { return $client->name; }, $clients); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $client = false; if ($this->method() == 'PATCH') { $routeAction = $this->route()->getAction(); $routeParameters = $this->route()->parameters(); $cid = false; if (isset($routeParameters['clientId'])) { $cid = $routeParameters['clientId']; } else { if (isset($routeParameters['one'])) { $cid = $routeParameters['one']; } } $client = \App\Client::find($cid); if (!$client) { dd('error'); } } switch ($this->method()) { case 'GET': case 'DELETE': return []; case 'PUT': return ['name' => 'required|unique:clients,name']; case 'PATCH': return ['name' => 'required|unique:clients,name,' . $client->id]; default: return []; break; } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $client = Client::findOrFail($id); $addressId = $client->addresses()->first()->id; $address = Address::findOrFail($addressId); return view('editAddress', compact('address', 'client')); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); $router->bind('client', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Client::findOrFail($id); }); $router->bind('bank', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return BankDetail::findOrFail($id); }); $router->bind('address', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Address::findOrFail($id); }); $router->bind('property', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return Property::findOrFail($id); }); $router->bind('agreement', function ($value, $route) { $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20); $id = $hashids->decode($value)[0]; return RentalAgreement::findOrFail($id); }); // }
/** * Remove the specified resource from storage. * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = Client::findOrFail($id); $name = $client->name . " " . $client->lastname; Client::destroy($id); return redirect(route('clients.index'))->with('message', 'Cliente ' . $name . ' eliminado corectamente'); }
public function clientsForUser($user = null) { if ($user != null) { return \App\Client::where('user_id', $user->id)->get(); } return \App\Client::where('user_id', $this->user()->id)->get(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = Client::findOrFail($id); $client->delete(); flash()->success('Client Deleted!'); return redirect()->route('clients.index'); }
/** * Show the application dashboard. * * @return Response */ public function index() { $clients = Client::all(); $projects = Project::all(); $notes = ClientNote::all(); return view('home')->with('clientCount', count($clients))->with('projectCount', count($projects))->with('noteCount', count($notes)); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $client = Client::findOrFail($id); $bankDetailId = $client->bankdetails()->first()->id; $bankDetail = BankDetail::findOrFail($bankDetailId); return view('editBankDetail', compact('bankDetail', 'client')); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('check_auth_user_password', function ($attribute, $value, $parameters, $validator) { return Hash::check($value, Auth::user()->password); }); // Make sure client email is not used by another client of current user Validator::extend('email_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) { if (Client::where('user_id', Auth::user()->id)->where('email', $value)->count()) { return false; } return true; }); // Make sure client phone number is not user by another client of current user Validator::extend('phone_number_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) { if (Client::where('user_id', Auth::user()->id)->where('phone_number', $value)->count()) { return false; } return true; }); Validator::extend('not_exists', function ($attribute, $value, $parameters, $validator) { return !DB::table($parameters[0])->where($parameters[1], $value)->count(); }); Validator::extend('is_not_in_auth_user_products', function ($attribute, $value, $parameters, $validator) { return !DB::table('products')->where('user_id', \Auth::user()->id)->where('code', $value)->count(); }); }
/** * Display a listing of client's albums. * * @return Response */ public function index($id) { $client = Client::find($id); $albums = $client->albums; $title = $client->first_name . ' ' . $client->last_name . ' Albums'; return view('admin.client_albums_index')->with('title', $title)->with('id', $id)->with('albums', $albums); }
public function create($id) { $client = Client::find($id); //created new route /projects/create/{id} //$clients = Client::lists('first_name', 'id'); //sends an array of 'first_name' => 'id' return view('projects.create', compact('client')); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('clients')->truncate(); //insert some dummy records Client::create(['name' => 'Idea7', 'country' => 'IN', 'status' => 'active']); Client::create(['name' => 'Sunpharma', 'country' => 'IN', 'status' => 'active']); }
/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request, $client_id = null) { $project_client = Client::find($client_id); $clients = $request->user()->clients; $view = $request->ajax() ? 'projects.create-modal' : 'projects.create'; return view($view, compact('clients', 'client_id'))->with(['client' => @$project_client]); }
/** * reads Project table by unique index * - if not found, emit a not found message. * - if found return the $project record to the caller. * * @param [in] $text * @return a record. */ public static function checkIfExists($text) { $client = Client::where('name', '=', $text)->first(); if (!is_null($client)) { appGlobals::existsMessage(appGlobals::getClientTableName(), $client->name, $client->id); } return $client; }
public function store(StoreColdRoomRequest $request) { $cliente = $request->input('cliente'); $pedido = $request->input('pedido'); $currentPage = 'cuartos'; Client::create($cliente)->coldRoomRequests()->create($pedido); return view('pages.cuartosCreate', ['posted' => true] + compact('currentPage')); }
public function store(Request $request) { $currentPage = 'cocinas'; $pedido = new KitchenRequest($request->input('pedido')); $pedido->secciones = $request->input('secciones'); Client::create($request->input('cliente'))->kitchenRequests()->save($pedido); return view('pages.cocinasCreate', ['posted' => true] + compact('currentPage')); }
public function index() { \App\Gini\Gapper\Client::init(); if (\App\Gini\Gapper\Client::getUserName()) { return view('dashboard', ['products_count' => Product::count(), 'servers_count' => Server::count(), 'clients_count' => Client::where('parent_id', 0)->count(), 'projects_count' => Project::count()]); } return view('login'); }
public function comments() { $client_data = Client::find(Auth::user()->id); $branch_data = $client_data->branch()->first(); //get the client branch information $comments = RestaurantFeedback::where('comment', '!=', '')->orderBy('id', 'desc')->take(6)->get(); return view('client.comments', compact('branch_data', 'comments')); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if (Gate::denies('addClient', new Client())) { abort(403, 'You are now allowed here'); } $client = Client::lists('name', 'id'); return view('project.create')->with('client', $client); }
public function edit(Request $request, $id) { $client = \App\Client::find($id); $client->name = $request->input('name'); $client->email = $request->input('email'); $client->save(); return redirect()->route('clients.details', $id); }