public function getView($id)
 {
     $company = Company::where("id", $id)->with(['customers' => function ($q) {
         $q->whereNull("user_id");
     }])->first();
     return view("company_profile.company_profile", ["company" => $company, "estimators" => User::where("company_id", $id)->count(), "jobs" => Job::where("company_id", $id)->count(), "customers" => $company->customers->count(), "estimatorz" => User::where("company_id", $id)->get()]);
 }
 /**
  * Update the users profile
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = User::find($request->input('user_id'));
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $user->username = $request->input('username');
     if ($request->input('password') != '') {
         $user->password = bcrypt($request->input('password'));
     }
     $user->update();
     $company = Company::where('user_id', $request->input('user_id'))->first();
     $company->name = $request->input('company_name');
     $company->description = $request->input('company_description');
     $company->phone = $request->input('company_phone');
     $company->email = $request->input('company_email');
     $company->address1 = $request->input('company_address');
     $company->address2 = $request->input('company_address2');
     $company->city = $request->input('company_city');
     $company->postcode = $request->input('company_postcode');
     if ($request->hasFile('logo')) {
         $file = $request->file('logo');
         $name = Str::random(25) . '.' . $file->getClientOriginalExtension();
         $image = Image::make($request->file('logo')->getRealPath())->resize(210, 113, function ($constraint) {
             $constraint->aspectRatio();
         });
         $image->save(public_path() . '/uploads/' . $name);
         $company->logo = $name;
     }
     $company->update();
     flash()->success('Success', 'Profile updated');
     return back();
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('article', function ($value) {
         return $this->getArticle()->where('slug', $value)->firstOrFail();
     });
     $router->bind('cong-ty', function ($value) {
         return \App\Company::where('slug', $value)->firstOrFail();
     });
     $router->bind('thiet-ke-thi-cong', function ($value) {
         return $this->designModel->getDesigns()->where('designs.slug', $value)->firstOrFail();
     });
     $router->bind('house', function ($value) {
         return $this->houseModel->getHouses()->where('houses.slug', $value)->firstOrFail();
     });
     $router->bind('company', function ($value) {
         return \App\Company::where('slug', $value)->firstOrFail();
     });
     $router->bind('project', function ($value) {
         return $this->projectModel->getProjects()->where('projects.slug', $value)->firstOrFail();
     });
     $router->model('owner', 'App\\House');
     $router->model('agency', 'App\\House');
     $router->model('message', 'App\\Message');
     parent::boot($router);
 }
 public function authenticate(Request $request)
 {
     // TODO: authenticate JWT
     $credentials = $request->only('email', 'password');
     // dd($request->all());
     // Validate credentials
     $validator = Validator::make($credentials, ['password' => 'required', 'email' => 'required']);
     if ($validator->fails()) {
         return response()->json(['message' => 'Invalid credentials', 'errors' => $validator->errors()->all()], 422);
     }
     // Get user by email
     $company = Company::where('email', $credentials['email'])->first();
     // Validate Company
     if (!$company) {
         return response()->json(['error' => 'Invalid credentials'], 422);
     }
     // Validate Password
     if (!Hash::check($credentials['password'], $company->password)) {
         return response()->json(['error' => 'Invalid credentials'], 422);
     }
     // Generate Token
     $token = JWTAuth::fromUser($company);
     // Get expiration time
     $objectToken = JWTAuth::setToken($token);
     $expiration = JWTAuth::decode($objectToken->getToken())->get('exp');
     return response()->json(['access_token' => $token, 'token_type' => 'bearer', 'expires_in' => $expiration]);
 }
 public function getViewCompany($id)
 {
     if (Auth::user()->company_id != $id && !$this->entrust->hasRole("super_admin")) {
         return "You are Not Authrized to View Any Other Company's Profile ";
     }
     $company = Company::where("id", $id)->with(["customers"])->first();
     return view("company", ["company" => $company]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //return view('Email.welcome');
     //
     $companies = \App\Company::where('active', 1)->get();
     $periods = \App\Period::where('active', 1)->get();
     return view('Admin.Registry.Company.company', ['companies' => $companies, 'periods' => $periods]);
 }
 public function index()
 {
     $data['is_showzhiye'] = Zhiye::where('z_show', '=', '1')->get();
     $data['allzhiye'] = Zhiye::all();
     $data['is_showcompany'] = Company::where('c_show', '=', '1')->get();
     $data['allcompany'] = Company::all();
     $data['alltime'] = Time::all();
     return view('contestRoom.index', $data);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request)
 {
     $data = $request->json()->get('data');
     $companyOld = $data[0]['companyOld'];
     $company = $data[0]['company'];
     $companyRec = \App\Company::where('name', $companyOld);
     if ($company != '') {
         $companyRec->update(['name' => $company]);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //get all companies using Eloquent all() method
     //$companies = Company::all();
     //since dataset is so large, let's use paginate instead => 100 results / page
     //https://laravel.com/docs/5.1/pagination
     $companies = Company::where('id', '>', 0)->simplePaginate(100);
     //return companies index view (view is in resources/views/companies/index.blade.php)
     return view('companies.index', compact('companies'));
 }
 public function getCompany($request)
 {
     $company = Company::where('domain', '=', 'http://trapi.com')->first();
     //$id = $company->id;
     /*
      * perform a look up for the company
      * find the id and the layout, styles whatever else we need to render the correct template.
      */
     return $company;
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function alias(Request $request)
 {
     if ($request->ajax()) {
         $user = \App\Company::where('alias', $request->get('alias'))->get();
         if ($user->count()) {
             return Response::json(array('msg' => 'true'));
         }
         return Response::json(array('msg' => 'false'));
     }
 }
Exemple #12
0
 /**
  * Check Unique Url
  *
  * @param Request $request
  * @return string Jquery Validation plugin only expect returns value string true or false
  */
 public function unique(Request $request, $id = null)
 {
     if ($request->ajax()) {
         $title = $request->input('title');
         if (is_null($id)) {
             return 0 == Company::where('title', $title)->count() ? 'true' : 'false';
         } else {
             return 0 == Company::where('title', $title)->where('id', '<>', $id)->count() ? 'true' : 'false';
         }
     }
 }
 public function getCompaniesWithJobs()
 {
     $companies = Company::where('status', 1)->with('category', 'jobs', 'people')->get();
     $companiesWithJobs = [];
     foreach ($companies as $company) {
         if ($company->jobs()->count() > 0) {
             array_push($companiesWithJobs, $company);
         }
     }
     return response()->json($companiesWithJobs);
 }
 public function doLogin()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     $user = CompanyModel::where('email', $email)->where('password', md5($password))->get();
     if (count($user) > 0) {
         Session::set('company_id', $user[0]->id);
         return Redirect::route('project');
     } else {
         $alert['msg'] = 'Email & Password is incorrect';
         $alert['type'] = 'danger';
         return Redirect::route('company.login')->with('alert', $alert);
     }
 }
Exemple #15
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index(Route $route)
 {
     $upcomingexhibitionevents = ExhibitionEvent::where('start_time', '>', date("Y-m-d H:i:s"))->take(4)->get();
     $currentlyexhibitionevents = ExhibitionEvent::where('start_time', '<', date("Y-m-d H:i:s"))->where('end_time', '>', date("Y-m-d H:i:s"))->take(4)->get();
     $tracklogins = Tracklogin::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(2)->get();
     $systemtracks = Systemtrack::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(5)->get();
     if (Auth::User()->type == 'company') {
         $user = User::find(Auth::User()->id);
         $company = Company::where('user_id', $user->id)->get();
         $company = $company[0];
         $companyId = $company->id;
         $exhibitors = Exhibitor::where('company_id', $companyId)->get();
         //$booths=array();
         $events = array();
         $i = 0;
         foreach ($exhibitors as $exhibitor) {
             $booths = Booth::where('exhibitor_id', $exhibitor->id)->get();
             foreach ($booths as $booth) {
                 $events[$i] = $booth->exhibition_event_id;
                 $i++;
             }
         }
         $events = array_unique($events);
         //var_dump($events); exit();
         $i = 0;
         $exhibitionevents = array();
         foreach ($events as $event) {
             $exhibitionevents[$i] = ExhibitionEvent::find($event);
             $i++;
         }
         // var_dump($exhibitionevents[0]); exit();
         $upcomingcompanyevents = array();
         $currentlycompanyevents = array();
         $finishedcompanyevents = array();
         $i = 0;
         foreach ($exhibitionevents as $exhibitionevent) {
             if ($exhibitionevent->start_time > date("Y-m-d H:i:s")) {
                 $upcomingcompanyevents[$i] = $exhibitionevent;
                 $i++;
             } elseif ($exhibitionevent->start_time < date("Y-m-d H:i:s") && $exhibitionevent->end_time > date("Y-m-d H:i:s")) {
                 $currentlycompanyevents[$i] = $exhibitionevent;
                 $i++;
             } else {
                 $finishedcompanyevents[$i] = $exhibitionevent;
                 $i++;
             }
         }
     }
     return view('home', compact('upcomingexhibitionevents', 'currentlyexhibitionevents', 'tracklogins', 'systemtracks', 'upcomingcompanyevents', 'currentlycompanyevents', 'finishedcompanyevents'));
 }
Exemple #16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $company_id = \App\Company::where('company_name', '=', 'ACME Corporation')->pluck('id');
     $officer_id = \App\Officer::where('last_name', '=', 'Bale')->pluck('id');
     DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 85, 'company_id' => $company_id, 'officer_id' => $officer_id]);
     $company_id = \App\Company::where('company_name', '=', 'The ABC Corporation')->pluck('id');
     $officer_id = \App\Officer::where('last_name', '=', 'Ronaldo')->pluck('id');
     DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 65, 'company_id' => $company_id, 'officer_id' => $officer_id]);
     $company_id = \App\Company::where('company_name', '=', 'YXZ Corporation')->pluck('id');
     $officer_id = \App\Officer::where('last_name', '=', 'Chan')->pluck('id');
     DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 50, 'company_id' => $company_id, 'officer_id' => $officer_id]);
     $company_id = \App\Company::where('company_name', '=', 'DIC Consulting Group')->pluck('id');
     $officer_id = \App\Officer::where('last_name', '=', 'Guerrero')->pluck('id');
     DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 80, 'company_id' => $company_id, 'officer_id' => $officer_id]);
     $company_id = \App\Company::where('company_name', '=', 'ACME Corporation')->pluck('id');
     $officer_id = \App\Officer::where('last_name', '=', 'Bale')->pluck('id');
     DB::table('projects')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'new_employment_commit' => 200, 'award_percent' => 75, 'company_id' => $company_id, 'officer_id' => $officer_id]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->only(['name', 'rut', 'phone', 'email', 'benefit', 'amount', 'month']);
     $count = Company::where('rut', '=', $input['rut'])->count();
     if ($count == 0) {
         //
         $rules = ['name' => 'required', 'rut' => 'required', 'phone' => 'required', 'email' => 'required|email', 'benefit' => 'required|numeric', 'amount' => 'required|numeric', 'month' => 'required|numeric|min:1'];
         $validation = \Validator::make($input, $rules);
         if ($validation->passes()) {
             $company = new Company($input);
             $company->save();
             return response()->json(["respuesta" => "Guardado"]);
         }
         $messages = $validation->errors();
         return response()->json($messages);
     }
     return response()->json(["respuesta" => "Ese rut ya esta registrado"]);
 }
Exemple #18
0
 public static function payment(int $id, $user_id, string $company_id) : array
 {
     $company_shift_start = Company::where('id', $company_id)->select('shift_day_start as day', 'shift_night_start as night')->first();
     $roster = Roster::find($id)->users()->where('users.id', $user_id)->first();
     if (count($roster) > 0 && $roster->pivot->real_start_time != null && $roster->pivot->real_start_time != null) {
         $start_str = strtotime($roster->pivot->real_start_time);
         $end_str = strtotime($roster->pivot->real_end_time);
         $arr_times = [];
         $payment = 0;
         $time = 0;
         for ($i = $start_str; $i <= $end_str; $i += 300) {
             $current_checking_time = date("Y-m-d H:i:s", $i);
             $custom_payment_amount = Payment::custom($current_checking_time);
             if ($custom_payment_amount == 0) {
                 $id = date("N", $i) - 1;
                 if (Common::isTimeBetween(date("H:i:s", $i), $company_shift_start->day, $company_shift_start->night)) {
                     $id .= "_day";
                 } else {
                     $id .= "_night";
                 }
                 if ($roster->pivot->is_supervisor == 1) {
                     $id .= "_supervisor";
                 } else {
                     $id .= "_worker";
                 }
                 !isset($arr_times[$id]) ? $arr_times[$id] = 1 : ($arr_times[$id] += 1);
             } else {
                 $payment += $custom_payment_amount * (1 / 12);
                 $time += 1 / 12;
             }
         }
         foreach ($arr_times as $key => $time_count) {
             list($day, $period, $type) = explode('_', $key);
             $amount = Payment::week($day, $period, $type, $company_id);
             $payment += $amount * (5 / 60 * $time_count);
             $time += $time_count;
             //return var_dump($amount);
         }
         return ['payment' => number_format((double) $payment, 2, '.', '') ?? 0, 'time' => $time];
     }
     return ['payment' => 0, 'time' => 0];
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function mis($months)
 {
     Excel::create('MIS&IT报销_' . $months, function ($excel) use($months) {
         $companies = Company::where('name', 'CROP')->get();
         foreach ($companies as $company) {
             $excel->sheet('new Sheet', function ($sheet) use($company, $months) {
                 $sheet->setAllBorders('thin');
                 // Set border for cells
                 $sheet->setBorder('A1', 'thin');
                 // Font family
                 $sheet->setFontFamily('Comic Sans MS');
                 $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 11, 'bold' => false)));
                 $employees_id = Employee::select('id')->where('department_name', 'MIS')->orWhere('department_name', 'IT')->get();
                 $sum = \App\MobileFees::where('company_id', 6)->wherein('employee_id', $employees_id)->where('months', $months)->with('company', 'employee')->sum('fee');
                 $mobilefees = \App\MobileFees::where('company_id', 6)->wherein('employee_id', $employees_id)->where('months', $months)->with('company', 'employee')->get();
                 $sheet->loadView('report.mis')->with('mobilefees', $mobilefees)->with('sum', $sum)->with('company_name', $company->name);
             });
         }
     })->download('xls');
 }
 /**
  * Show Dashboard View
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $segment = \Request::url();
     $search = ['http://', 'https://', '.madesimpleapp', '.co.uk', '/' . \Request::segment(1)];
     $replace = ['', '', '', '', ''];
     $output = str_replace($search, $replace, $segment);
     $company = Company::where('user_id', Auth::user()->id);
     if (Auth::check() && Auth::user()->role != 'Admin' || $company == $output) {
         //$notifications = Notifications::all();
         $user = Auth::user();
         $listOfNotificationIdsUserHasSeen = $user->notifications->lists('id');
         $notifications = DB::table('notifications')->whereNotIn('id', $listOfNotificationIdsUserHasSeen)->orderBy('created_at', 'DESC')->take(1)->get();
         return view('dashboard', compact('notifications'));
     }
     if (Auth::check() && Auth::user()->role == 'Admin') {
         $accounts = User::where('role', '!=', 'Admin')->paginate(10);
         return view('admin.dashboard', compact('accounts'));
     }
     return true;
 }
	/**
	 * Auto generated seed file
	 *
	 * @return void
	 */
	public function run()
	{
		$faker = Faker::create();
        		foreach(range(1, 30) as $index)
		{
			$arr_distribute = Company::where('is_distribute','=',1)->lists('id');
			$company_id = $faker->randomElement($array = $arr_distribute);
			$date = $faker->dateTimeBetween($startDate = '-6 months', $endDate = 'now');
			$address_id = $index+20;
			$company_phone = $faker->phoneNumber;
			$company_email = $faker->companyEmail;
			Purchaseorder::create([
							'company_id'		=> $company_id,
							'date'			=> $date,
							'address_id'		=> $address_id,
							'company_phone'	=> $company_phone,
							'company_email'	=> $company_email,
							'status'			=> 1
						]);
		}
	}
Exemple #22
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Log::info('Begin the send-bill-notice command.');
     $now = Carbon::now();
     $beforeDay = \Config::get('app.day_before_send_bill_notice');
     $billList = CompanyBill::where('deadline', '=', $now->addDay($beforeDay)->format('Y-m-d 00:00:00'))->where('is_paid', CompanyBill::IS_PAID_NO)->select('company_id', 'user_id')->distinct()->get();
     foreach ($billList as $bill) {
         $map = ['user_id' => $bill->user_id, 'id' => $bill->company_id];
         $customerCompany = CustomerCompany::where($map)->first();
         if (!$customerCompany) {
             Log::error('send-bill-notice:Not find company.');
             continue;
         }
         $contact = $customerCompany->getDefaultContact();
         if (!$contact) {
             Log::error('send-bill-notice:Not find company contact.');
             continue;
         }
         $company = Company::where('id', $bill->user_id)->first();
         if (!$company) {
             Log::error('send-bill-notice:Not find daizhang user.');
             continue;
         }
         $sql = "SELECT sum(cb.grand_total) as grand_total, count(cb.id) as total_item FROM company_bills cb  where cb.is_paid=0 and cb.user_id={$bill->user_id} and cb.company_id={$bill->company_id}";
         $unpaidResult = DB::select($sql);
         if (count($unpaidResult) == 0) {
             continue;
         }
         $totalItem = $unpaidResult[0]->total_item;
         $grandTotal = $unpaidResult[0]->grand_total;
         $sms = new Sms();
         $text = "【代账通】尊敬的客户,贵公司尚有未支付费用 {$totalItem} 项,共计 ¥{$grandTotal} 元 。请及时联系 {$company->name} 缴纳。";
         $result = $sms->sendMessage($text, $contact->mobile);
         if ($result->code != 0) {
             Log::error('send-bill-notice:Send SMS error.' . $result->detail);
             continue;
         }
     }
     Log::info('End the send-bill-notice command.');
 }
Exemple #23
0
 public function destroy($id)
 {
     $user = User::find($id);
     $companies = Company::where('user_id', '=', $id)->get();
     if (count($companies) > 0) {
         foreach ($companies as $company) {
             $campains = Campain::where('company_id', '=', $company->id)->get();
             if (count($campains) > 0) {
                 foreach ($campains as $campain) {
                     $links = Link::where('campain_id', '=', $campain->id)->get();
                     if (count($links) > 0) {
                         foreach ($links as $link) {
                             $link->delete();
                         }
                     }
                     $campain->delete();
                 }
             }
         }
         $company->delete();
     }
     $user->delete();
     return redirect('login/');
 }
 public function refereeSubmittedTwo(Request $request)
 {
     $code = $request->segment(2);
     $refTwo = References::where('id', $request->input('referee_id'))->first();
     $refTwo->referee_name = $request->input('name');
     $refTwo->referee_start_date = $request->input('applicant_started');
     $refTwo->referee_end_date = $request->input('date_left');
     $refTwo->referee_email = $request->input('email_address');
     $refTwo->position = $request->input('position');
     $refTwo->leaving = $request->input('reason_for_leaving');
     $refTwo->completedtwo = 'Yes';
     $refTwo->re_employ = $request->input('re_employ');
     $refTwo->update();
     $fields = Fields::create($request->except('_token', 're_employ', 'referee_id', 'first_name', 'middle_name', 'surname', 'name', 'phone', 'position', 'email_address', 'applicant_started', 'date_left', 'reason_for_leaving', 'code'));
     //$settings = Settings::create($request->only('label', 'label2', 'label3', 'label4', 'label5', 'label6', 'label7', 'label8', 'label9', 'label10', 'company_id'));
     $settings = Settings::where('id', $refTwo->settings_id)->first();
     $settings->fields_id = $fields->id;
     $settings->update();
     $apps = Applications::where('code', $code)->first();
     $apps->reference_two_id = $refTwo->id;
     $apps->update();
     $fields->settings_id = $settings->id;
     $fields->references_id = $refTwo->id;
     $fields->update();
     $segment = \Request::url();
     $search = ['http://', 'https://', '.madesimpleapp', '.co.uk/', \Request::segment(1) . '/', \Request::segment(2) . '/', \Request::segment(3)];
     $replace = ['', '', '', '', '', '', ''];
     $output = str_replace($search, $replace, $segment);
     $company = Company::where('url', $output)->first();
     $refTwo->settings_id = $settings->id;
     $refTwo->company_id = $company->id;
     $refTwo->applications_id = $apps->id;
     $refTwo->update();
     flash()->success('Success', 'Thank you for submission');
     return redirect('/');
 }
 /**
  * list booth of certain company in certain events
  * @param  integer $id
  * @return Response
  */
 public function listboothsofcompanyinthisevent($id)
 {
     if (!$this->companyAuth($id)) {
         return view('errors.404');
     }
     $user = User::find($id);
     $company = Company::where('user_id', $user->id)->get();
     $company = $company[0];
     $companyId = $company->id;
     $exhibitors = Exhibitor::where('company_id', $companyId)->get();
     $booths = array();
     $i = 0;
     foreach ($exhibitors as $exhibitor) {
         $booths = Booth::where('exhibitor_id', $exhibitor->id)->get();
         $booths[$i] = $booths[0];
         $i++;
     }
     // var_dump($booths); exit();
     return view('booths.index', compact('booths'));
 }
Exemple #26
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Company;
use App\User;
Route::get('/', ["uses" => "DashboardController@index", "middleware" => "auth"]);
Route::get('customer', ["as" => "customer-estimations", "uses" => "CustomersController@getEstimations"]);
Route::controller("customer", "CustomersController");
Route::controller("test", "TestController");
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::controller("company", "CompanyController");
Route::controller("shop", "ShopsController");
Route::controller("job", "JobsController");
Route::get("angular", function () {
    $company = Company::where("id", 5)->with(["customers", "jobs"])->first();
    return $company;
});
Exemple #27
0
        <div class="col-md-12">
            <div class="form-login">
                <?php 
if (App::environment('local')) {
    $segment = \Request::url();
    $search = ['http://', 'https://', '.applications', '.app', '/' . \Request::segment(1)];
    $replace = ['', '', '', '', ''];
    $output = str_replace($search, $replace, $segment);
    $company = \App\Company::where('url', $output)->first();
}
if (App::environment('production')) {
    $segment = \Request::url();
    $search = ['http://', 'https://', '.madesimpleltd', '.co.uk', '/' . \Request::segment(1)];
    $replace = ['', '', '', '', ''];
    $output = str_replace($search, $replace, $segment);
    $company = \App\Company::where('url', $output)->first();
}
?>
                @if (! empty($company->logo))
                    <img src="/uploads/{{ $company->logo }}" width="100" style="display: flex; justify-content: center; align-items: center;margin: 0px 0px 30px 80px;  ">
                @else
                    <h4>Login</h4>
                @endif
                @if (count($errors) > 0)
                    <div class="alert alert-danger">
                        <strong>Whoops!</strong> There were some problems with your input.<br><br>
                            @foreach ($errors->all() as $error)
                                <span>{{ $error }}</span><br /><br />
                            @endforeach
                    </div>
                @endif
Exemple #28
0
 public function getCompany()
 {
     $company = Company::where('user_id', '=', $this->id)->first();
     return $company;
 }
Exemple #29
0
 private static function generateCompanyStrId($name)
 {
     // $name = strtolower(trim($name));
     //   	$name = preg_replace('/[\x00-\x1F\x80-\xFF]/','', $name);
     //   	$name = preg_replace('@[/\\\]@', ' ', $name);
     //   	$remove_chars = ['&#39;','\/','.','\'',',', '(', ')','`','#','+', '=','"', '?','@','$','&'];
     //   	$str_id = str_replace([' - ',' ','*','&amp;'], '-', str_replace($remove_chars, '', $name));
     //   	$str_id = preg_replace('/-+/', '-', $str_id);]]]
     $str_id = str_slug($name, "-");
     if (empty($str_id)) {
         $str_id = 'emptyid';
     } else {
         $count = Company::where(['str_id' => $str_id])->count();
         if ($count > 0) {
             $str_id .= '-' . ($count + 1);
         }
     }
     return $str_id;
 }
 public function phoneUpload(Request $request)
 {
     if ($request->hasFile('phonefile')) {
         $date = Carbon::now()->format("Y_m_d");
         $path = base_path() . "/up/" . "Phone/" . $date . "/";
         $ext = $request->file('phonefile')->getClientOriginalExtension();
         $extmine = $request->file('phonefile')->getClientMimeType();
         $exts = collect(['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
         if ($exts->contains($extmine)) {
             $request->file('phonefile')->move($path, Carbon::now()->timestamp . "." . $ext);
             $filename = $path . Carbon::now()->timestamp . "." . $ext;
             /* Import Excel file*/
             Excel::load($filename, function ($reader) {
                 $rule = ['number' => 'required|unique:phones'];
                 $sheetsCount = $reader->getSheetCount();
                 for ($i = 0; $i < $sheetsCount; $i++) {
                     $sheets = $reader->getSheet($i)->toArray();
                     $sheetCount = count($sheets);
                     for ($j = 1; $j < $sheetCount; $j++) {
                         /*
                         *  $table->integer('company_id')->unsigned();
                            $table->boolean('isShared')->default(false);
                            $table->string('department_name')->nullable();
                            $table->boolean('isActived')->default(true);
                            $table->string('number')->unique();
                            $table->integer('payment_company_id')->unsigned();
                            $table->integer('category_id')->unsigned();
                         */
                         if ($sheets[$j][6] == 'EXT_CDMA') {
                             $data['number'] = trim($sheets[$j][1]);
                             $data['company_id'] = Company::where('name', trim($sheets[$j][3]))->value('id');
                             $data['payment_company_id'] = $data['company_id'];
                             $data['category_id'] = PhoneCategory::where('name', 'CDMA')->value('id');
                             $data['department_name'] = $sheets[$j][4];
                             $validator = \Validator::make($data, $rule);
                             if ($validator->fails()) {
                             } else {
                                 Phone::create($data);
                             }
                         }
                         /* $validator=\Validator::make($data,$rule);
                                                 if($validator->fails()){
                         
                                                 }else{
                         
                                                 }*/
                     }
                 }
             });
         } else {
             return back()->with('message', '文件格式不对');
         }
     }
     return back();
 }