function getControlpanel() { $deliverables = \p4\Deliverable::where('client_id', '=', $authuser->client_id)->get(); $client = \p4\Client::where('id', '=', $authuser->client_id)->first(); $clientname = $client->name; return view('dashboard.dashboard', ['deliverables' => $deliverables, 'authuser' => $authuser, 'clientname' => $clientname]); }
public function addDeliverable(Request $request) { $messages = ['not_in' => "You have to choose a client.", 'url' => "Your url must be in the form http://domain.com"]; $this->validate($request, ['deliverable_name' => 'required|max:25', 'client_id' => 'not_in:0', 'deliverable_url' => 'url'], $messages); $deliverable = new \p4\Deliverable(); $user = \Auth::user(); $client = \p4\Client::find($request->client_id); $file = \Request::file('deliverable_file'); if ($file) { $extension = $file->getClientOriginalExtension(); $filename = $file->getClientOriginalName(); $file->move(public_path() . '/uploads/', $filename); $location = '/uploads/' . $filename; $deliverable->attachment = $location; } $deliverable->url = \Request::get('deliverable_url'); $deliverable->name = \Request::get('deliverable_name'); $deliverable->created_by = $user->id; $deliverable->date_delivered = Date('Y-m-d H:i:s'); $deliverable->client_id = \Request::get('client_id'); $deliverable->status = \Request::get('status'); $deliverable->client()->associate($client); $deliverable->save(); $data = array('client' => $client, 'deliverable' => $deliverable); /**sends email confirmation to client after deliverable is added**/ \Mail::send('emails.deliverable-available', $data, function ($message) use($client, $deliverable) { $recepient_email = $client->email; $recepient_name = $client->name; $subject = 'Your deliverable is now ready for you to review'; $message->to($recepient_email, $recepient_name)->subject($subject); }); \Session::flash('message', 'Your Deliverable Has Been Uploaded'); return redirect()->back(); }
/** * Run the database seeds. * * @return void */ public function run() { $client_id = \p4\Client::where('name', '=', 'Roth Rugs')->pluck('id')->first(); DB::table('deliverables')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Logo', 'created_by' => 1, 'client_id' => $client_id, 'status' => 'Pending Approval', 'date_delivered' => Carbon\Carbon::now()->toDateTimeString(), 'attachment' => 'http://xtramilemedia.com/wp-content/uploads/2014/12/XMM_LOGO_web_center1-e1419371859936.png']); $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first(); DB::table('deliverables')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Design Approval', 'created_by' => 1, 'client_id' => $client_id, 'status' => 'Pending Approval', 'date_delivered' => Carbon\Carbon::now()->toDateTimeString()]); $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first(); DB::table('deliverables')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Contract', 'created_by' => 1, 'client_id' => $client_id, 'status' => 'Pending Approval', 'date_delivered' => Carbon\Carbon::now()->toDateTimeString(), 'url' => 'http://www.contract.com']); }
public function _construct() { $this->{$authuser} = $request->user(); $this->{$deliverables} = \p4\Deliverable::where('client_id', '=', $authuser->client_id)->get(); if ($authuser->client_id) { $client = \p4\Client::where('id', '=', $authuser->client_id)->first(); $this->{$clientname} = $client->name; } else { $this->{$clientname} = 'Agency'; } }
/** * Run the User table database seeds. * * @return void */ public function run() { $client_id = \p4\Client::where('name', '=', 'Roth Rugs')->pluck('id')->first(); $role_id = \p4\Role::where('name', '=', 'Agency')->pluck('id')->first(); DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Jill", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "role_id" => $role_id]); $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first(); $role_id = \p4\Role::where('name', '=', 'Client')->pluck('id')->first(); DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Jamal", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "role_id" => $role_id]); $client_id = \p4\Client::where('name', '=', 'Uptown Realty')->pluck('id')->first(); $role_id = \p4\Role::where('name', '=', 'Agency')->pluck('id')->first(); DB::table('users')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), "name" => "Shaun", "email" => "*****@*****.**", "password" => bcrypt("helloworld"), "client_id" => $client_id, "admin" => "1", "role_id" => $role_id]); }
public static function clientsForDropdown() { #get all clients $clients = \p4\Client::orderBy('name', 'ASC')->get(); #build array for client dropdown $clients_for_dropdown = []; $clients_for_dropdown[0] = 'Choose a client'; foreach ($clients as $client) { $clients_for_dropdown[$client->id] = $client->name; } return $clients_for_dropdown; }
public function addUser(Request $request) { $messages = ['client.not_in' => "You have to choose a client.", 'role.not_in' => "You have to choose a role."]; $this->validate($request, ['user_name' => 'required|max:25', 'user_email' => 'required', 'client' => 'not_in:0', 'role' => 'not_in:0'], $messages); $admin = \Request::get('admin'); $client_id = \Request::get('client'); $role_id = \Request::get('role'); $client = \p4\Client::find($client_id); $role = \p4\Role::find($role_id); $user = new \p4\User(); if ($admin == 'true') { $user->admin = '1'; } $user->name = \Request::get('user_name'); $user->email = \Request::get('user_email'); $user->client_id = $client->id; $user->role_id = $role->id; $user->role()->associate($role); $user->client()->associate($client); $user->save(); \Session::flash('message', 'User has been successfully created'); return redirect()->back(); }