Inheritance: extends Illuminate\Database\Eloquent\Model
Exemplo n.º 1
2
 public function run()
 {
     $faker = Faker::create();
     //create some users for every role
     for ($i = 0; $i < 10; $i++) {
         //persons
         Person::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthday' => $faker->dateTimeBetween('-40 years', '-16 years'), 'sex' => $faker->randomElement(['male', 'female']), 'home_phone' => $faker->e164PhoneNumber, 'user' => ['nickname' => $faker->userName, 'email' => $faker->unique()->email, 'role' => 'person', 'password' => \Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@' . $faker->userName, 'facebook' => $faker->userName, 'preferences' => '{"product_viewed":[],"product_purchased":[],"product_shared":[],"product_categories":[],"my_searches":[]}']]);
     }
     for ($i = 0; $i < 8; $i++) {
         $company_name = $faker->company;
         //business
         Business::create(['business_name' => $company_name, 'creation_date' => $faker->date(), 'local_phone' => $faker->e164PhoneNumber, 'user' => ['nickname' => $faker->userName, 'email' => $faker->unique()->email, 'role' => 'business', 'type' => $faker->randomElement(['normal', 'trusted']), 'password' => \Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@' . $company_name, 'facebook' => $company_name, 'preferences' => '{"product_viewed":[],"product_purchased":[],"product_shared":[],"product_categories":[],"my_searches":[]}']]);
     }
 }
Exemplo n.º 2
0
 /**
  * store Business
  *
  * @param  BusinessFormRequest $request Business form Request
  * @return Response                     Redirect
  */
 public function store(BusinessFormRequest $request)
 {
     $this->log->info('Manager\\BusinessController@store');
     // Search Existing
     $existingBusiness = Business::withTrashed()->where(['slug' => $request->input('slug')])->first();
     // If found
     if ($existingBusiness !== null) {
         $this->log->info("Manager\\BusinessController@store: Found existing businessId:{$existingBusiness->id}");
         // If owned, restore
         if (auth()->user()->isOwner($existingBusiness)) {
             $this->log->info("Manager\\BusinessController@store: Restoring owned businessId:{$existingBusiness->id}");
             $existingBusiness->restore();
             Flash::success(trans('manager.businesses.msg.store.restored_trashed'));
             return redirect()->route('manager.business.service.create', $existingBusiness);
         }
         # If not owned, return message
         $this->log->info("Manager\\BusinessController@store: Already taken businessId:{$existingBusiness->id}");
         Flash::error(trans('manager.businesses.msg.store.business_already_exists'));
         return redirect()->route('manager.business.index');
     }
     // Register new Business
     $business = new Business($request->all());
     $category = Category::find($request->get('category'));
     $business->strategy = $category->strategy;
     $business->category()->associate($category);
     $business->save();
     auth()->user()->businesses()->attach($business);
     auth()->user()->save();
     // Generate local notification
     $business_name = $business->name;
     Notifynder::category('user.registeredBusiness')->from('App\\User', auth()->user()->id)->to('App\\Business', $business->id)->url('http://localhost')->extra(compact('business_name'))->send();
     // Redirect success
     Flash::success(trans('manager.businesses.msg.store.success'));
     return redirect()->route('manager.business.service.create', $business);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Business $business, Request $request)
 {
     $this->log->info("BusinessServiceController: store: businessId:{$business->id}");
     $dates = $request->get('vacancy');
     $success = false;
     foreach ($dates as $date => $vacancy) {
         foreach ($vacancy as $serviceId => $capacity) {
             switch (trim($capacity)) {
                 case '':
                     // Dont update, leave as is
                     $this->log->info("BusinessServiceController: store: [ADVICE] Blank vacancy capacity value businessId:{$business->id}");
                     break;
                 default:
                     $start_at = Carbon::parse($date . ' ' . $business->pref('start_at'))->timezone($business->timezone);
                     $finish_at = Carbon::parse($date . ' ' . $business->pref('finish_at', '20:00:00'))->timezone($business->timezone);
                     $vacancy = Vacancy::updateOrCreate(['business_id' => $business->id, 'service_id' => $serviceId, 'date' => $date], ['capacity' => intval($capacity), 'start_at' => $start_at, 'finish_at' => $finish_at]);
                     $success = true;
                     break;
             }
         }
     }
     if ($success) {
         Flash::success(trans('manager.vacancies.msg.store.success'));
         return redirect()->route('manager.business.show', [$business]);
     }
     $this->log->info("BusinessServiceController: store: [ADVICE] Nothing to update businessId:{$business->id}");
     Flash::warning(trans('manager.vacancies.msg.store.nothing_changed'));
     return redirect()->back();
 }
Exemplo n.º 4
0
 /**
  * post Store
  *
  * @param  Request $request Input data of booking form
  * @param  ConciergeServiceLayer $concierge Concierge injection
  * @return Response         Redirect to Appointments listing
  */
 public function postStore(Request $request, ConciergeServiceLayer $concierge)
 {
     $this->log->info('AgendaController: postStore');
     $issuer = auth()->user();
     $business = Business::findOrFail($request->input('businessId'));
     $contact = $issuer->getContactSubscribedTo($business);
     $service = Service::find($request->input('service_id'));
     $datetime = Carbon::parse($request->input('_date') . ' ' . $business->pref('start_at'))->timezone($business->timezone);
     $comments = $request->input('comments');
     $appointment = $concierge->makeReservation($issuer, $business, $contact, $service, $datetime, $comments);
     if (false === $appointment) {
         $this->log->info('AgendaController: postStore: [ADVICE] Unable to book ');
         Flash::warning(trans('user.booking.msg.store.error'));
         return redirect()->route('user.booking.list');
     }
     $appointmentPresenter = $appointment->getPresenter();
     if ($appointment->exists) {
         $this->log->info('AgendaController: postStore: Appointment saved successfully ');
         Event::fire(new NewBooking($issuer, $appointment));
         Flash::success(trans('user.booking.msg.store.success', ['code' => $appointmentPresenter->code()]));
     } else {
         $this->log->info('AgendaController: postStore: [ADVICE] Appointment is duplicated ');
         Flash::warning(trans('user.booking.msg.store.sorry_duplicated', ['code' => $appointmentPresenter->code()]));
     }
     return redirect()->route('user.booking.list');
 }
Exemplo n.º 5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $albums = PhotoAlbum::where('user_id', $id)->where('type', 'album')->get();
     $business = Business::findOrFail($id);
     return view('photoAlbum.show')->withAlbums($albums)->withBusiness($business);
 }
Exemplo n.º 6
0
 public function all()
 {
     $businesses = Business::all();
     $categories = Category::all();
     $page = "Toutes les entreprises";
     return view('businesses', compact('businesses', 'page', 'categories'));
 }
Exemplo n.º 7
0
 private function getContacts($expression)
 {
     $businesses = Business::whereIn('id', $this->scope['businessesIds'])->get();
     foreach ($businesses as $business) {
         $collection = $business->contacts()->where(function ($query) use($expression) {
             $query->where('lastname', 'like', $expression . '%')->orWhere('firstname', 'like', $expression . '%')->orWhere('nin', $expression)->orWhere('mobile', 'like', '%' . $expression);
         })->get();
         $this->results['contacts'] = $collection;
     }
 }
Exemplo n.º 8
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->model('contact', 'App\\Contact');
     $router->model('business', 'App\\Business');
     $router->model('service', 'App\\Service');
     $router->model('appointment', 'App\\Appointment');
     $router->bind('business_slug', function ($business_slug) {
         return Business::where('slug', $business_slug)->get();
     });
 }
Exemplo n.º 9
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $appointmentId = $this->get('appointment');
     $businessId = $this->get('business');
     $issuer = auth()->user();
     $business = Business::find($businessId);
     $appointment = Appointment::find($appointmentId);
     $authorize = $appointment->issuer->id == $issuer->id || $issuer->isOwner($business);
     # \Log::info("Authorize AlterAppointmentRequest for issuer:{$issuer->id} appointment:$appointmentId business:$businessId authorize:$authorize");
     return $authorize;
 }
Exemplo n.º 10
0
 /**
  * To handle all the mesaging functionality
  *
  * @param  int  $id
  * @return Response
  */
 public function index(Request $request)
 {
     $user = User::find(Auth::user()->id);
     $userDetail = UserDetail::where('userId', $user->id)->first();
     $business = Business::find($userDetail->businessId);
     if (empty($business)) {
         $business = (object) array_merge($user->toArray(), $userDetail->toArray());
     } else {
         $business = (object) array_merge($user->toArray(), $userDetail->toArray(), $business->toArray());
     }
     return view('message.index')->withBusiness($business);
 }
Exemplo n.º 11
0
 public function run()
 {
     //create basic admin user
     $faker = Faker::create();
     Person::create(['first_name' => 'Admin', 'last_name' => 'root', 'user' => ['nickname' => 'admin', 'email' => '*****@*****.**', 'role' => 'admin', 'type' => 'trusted', 'password' => \Hash::make('admin'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@websarrollo', 'facebook' => 'websarrollo', 'preferences' => '{"product_viewed":[],"product_purchased":[],"product_shared":[],"product_categories":[],"my_searches":[]}']]);
     //developer (admin)
     $admin = Person::create(['first_name' => 'AntVel', 'last_name' => 'Developer', 'user' => ['nickname' => 'dev', 'email' => '*****@*****.**', 'role' => 'admin', 'type' => 'trusted', 'password' => \Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@websarrollo', 'facebook' => 'websarrollo']]);
     //seller
     $company_name = 'antvel seller';
     $seller = Business::create(['business_name' => $company_name, 'creation_date' => $faker->date(), 'local_phone' => $faker->phoneNumber, 'user' => ['nickname' => 'antvelseller', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@seller', 'facebook' => $company_name]])->user;
     //buyer
     $buyer = Person::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthday' => $faker->dateTimeBetween('-40 years', '-16 years'), 'sex' => 'male', 'user' => ['nickname' => 'antvelbuyer', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@buyer', 'facebook' => 'buyer']])->user;
 }
 /**
  * post Import
  *
  * @param  Business $business Business to import Contacts to
  * @param  Request  $request  Submitted form data
  * @return Response           Redirect to Business addressbook
  */
 public function postImport(Business $business, Request $request)
 {
     $this->log->info("BusinessContactImportExportController: postImport: businessId:{$business->id}");
     $csv = $this->csvToArray(Request::get('data'));
     foreach ($csv as $import) {
         $import = array_map(function ($item) {
             return $item == 'NULL' ? null : $item;
         }, $import);
         if ($import['birthdate'] !== null) {
             $date = \DateTime::createFromFormat('Ymd', $import['birthdate']);
             $import['birthdate'] = $date->format('m/d/Y');
         }
         $notes = $import['notes'];
         unset($import['notes']);
         $contact = Contact::create($import);
         $business->contacts()->attach($contact, ['notes' => $notes]);
         $business->save();
     }
     $count = count($csv);
     $this->log->info("BusinessContactImportExportController: Imported {$count} contacts to businessId:{$business->id}");
     Notifynder::category('user.importedContacts')->from('App\\User', auth()->user()->id)->to('App\\Business', $business->id)->url('http://localhost')->extra(compact('count'))->send();
     Flash::success(trans('manager.contacts.msg.import.success'));
     return redirect()->route('manager.business.contact.index', [$business]);
 }
Exemplo n.º 13
0
 public function run()
 {
     $faker = Faker::create();
     $businesses = Business::get();
     for ($i = 0; $i < 10; $i++) {
         $price = $faker->numberBetween(1, 99);
         $stock = $faker->numberBetween(20, 50);
         $product = Product::create(['category_id' => $faker->numberBetween(1, 9), 'user_id' => '3', 'name' => 'VIRTUAL ' . $faker->unique()->catchPhrase, 'description' => $faker->text(500), 'price' => $price, 'stock' => $stock, 'sale_counts' => $faker->randomNumber(9), 'view_counts' => $faker->randomNumber(9), 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'features' => json_encode(['images' => ['/img//pt-default/' . $faker->unique()->numberBetween(1, 330) . '.jpg', '/img//pt-default/' . $faker->unique()->numberBetween(1, 330) . '.jpg', '/img//pt-default/' . $faker->unique()->numberBetween(1, 330) . '.jpg', '/img//pt-default/' . $faker->unique()->numberBetween(1, 330) . '.jpg', '/img//pt-default/' . $faker->unique()->numberBetween(1, 330) . '.jpg']]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'tags' => json_encode($faker->word . ',' . $faker->word . ',' . $faker->word), 'type' => 'key']);
         $faker->unique($reset = true);
         $virtual = VirtualProduct::create(['product_id' => $product->id, 'key' => 'undefined', 'status' => 'cancelled']);
         for ($j = 1; $j < $stock; $j++) {
             $virtual = VirtualProduct::create(['product_id' => $product->id, 'key' => $faker->uuid, 'status' => 'open']);
         }
     }
 }
Exemplo n.º 14
0
 public function run()
 {
     $faker = Faker::create();
     $businesses = Business::get();
     $numCategories = DB::table('categories')->count();
     for ($i = 0; $i < 150; $i++) {
         $price = $faker->numberBetween(1, 99);
         $stock = $faker->numberBetween(20, 50);
         $id = Product::create(['category_id' => $faker->numberBetween(1, $numCategories), 'user_id' => '3', 'name' => $faker->unique()->catchPhrase, 'description' => $faker->text(500), 'price' => $price, 'stock' => $stock, 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'features' => json_encode(["images" => ['/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg'], "weight" => $faker->numberBetween(10, 150) . ' ' . $faker->randomElement(["Mg", "Gr", "Kg", "Oz", "Lb"]), "dimensions" => $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' ' . $faker->randomElement(["inch", "mm", "cm"]), "color" => $faker->safeColorName]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'low_stock' => $faker->randomElement([5, 10, 15]), 'tags' => $faker->word . ',' . $faker->word . ',' . $faker->word]);
         if ($faker->numberBetween(0, 1)) {
             $percentage = $faker->randomElement([10, 15, 25, 35, 50]);
             ProductOffer::create(['product_id' => $id->id, 'day_start' => $faker->dateTime(), 'day_end' => $faker->dateTimeBetween('now', '+1 years'), 'percentage' => $percentage, 'price' => $percentage * $price / 100, 'quantity' => round($stock / 2)]);
         }
     }
 }
Exemplo n.º 15
0
 public function run()
 {
     $faker = Faker::create();
     $businesses = Business::get();
     $numCategories = DB::table('categories')->count();
     for ($i = 0; $i < 150; $i++) {
         $price = $faker->numberBetween(1, 99);
         $stock = $faker->numberBetween(20, 50);
         $id = Product::create(['category_id' => $faker->numberBetween(1, $numCategories), 'user_id' => '3', 'status' => 1, 'type' => 'software', 'sale_counts' => $faker->randomNumber(9), 'view_counts' => $faker->randomNumber(9), 'name' => $faker->unique()->catchPhrase, 'description' => $faker->text(500), 'price' => $price, 'stock' => $stock, 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'features' => json_encode(['images' => ['/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg'], trans('globals.product_features.weight') => $faker->numberBetween(10, 150) . ' ' . $faker->randomElement(['Mg', 'Gr', 'Kg', 'Oz', 'Lb']), trans('globals.product_features.dimensions') => $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' ' . $faker->randomElement(['inch', 'mm', 'cm']), trans('globals.product_features.color') => $faker->safeColorName]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'low_stock' => $faker->randomElement([5, 10, 15]), 'tags' => json_encode($faker->word . ',' . $faker->word . ',' . $faker->word)]);
         if ($faker->numberBetween(0, 1)) {
             $percentage = $faker->randomElement([10, 15, 25, 35, 50]);
             ProductOffer::create(['product_id' => $id->id, 'day_start' => $faker->dateTime(), 'day_end' => $faker->dateTimeBetween('now', '+1 years'), 'percentage' => $percentage, 'price' => $percentage * $price / 100, 'quantity' => round($stock / 2)]);
         }
     }
 }
Exemplo n.º 16
0
 public function getGet(Request $request, $page = 1)
 {
     $res = ['response' => 'YES', 'status' => 0];
     $businesses = Business::apiGet($page, 10);
     if (is_array($businesses)) {
         $res['status'] = 1;
         if (count($businesses) > 0) {
             $res['html'] = view('auth.business.templet.businesses', ['businesses' => $businesses])->render();
         } else {
             $res['html'] = '';
         }
     } else {
         $res['msgError'] = '加载失败,请稍后再试';
     }
     return response()->json($res);
 }
Exemplo n.º 17
0
 public function run()
 {
     #create basic admin user
     $faker = Faker::create();
     Person::create(['first_name' => 'Admin', 'last_name' => 'root', 'user' => ['nickname' => 'admin', 'email' => '*****@*****.**', 'role' => 'admin', 'type' => 'trusted', 'password' => \Hash::make('admin'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@websarrollo', 'facebook' => 'websarrollo', 'preferences' => '{"product_viewed":[],"product_purchased":[],"product_shared":[],"product_categories":[],"my_searches":[]}']]);
     /**
      * Creating users with real emails for test
      * email info:
      * dev: mA9msb78VX
      * seller: ykH0dvY96P
      * buyer: TLlJk0r17w
      */
     #developer (admin)
     $admin = Person::create(['first_name' => 'AntVel', 'last_name' => 'Developer', 'user' => ['nickname' => 'dev', 'email' => '*****@*****.**', 'role' => 'admin', 'type' => 'trusted', 'password' => \Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@websarrollo', 'facebook' => 'websarrollo']]);
     #seller
     $company_name = 'antvel seller';
     $seller = Business::create(['business_name' => $company_name, 'creation_date' => $faker->date(), 'local_phone' => $faker->phoneNumber, 'user' => ['nickname' => 'antvelseller', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@seller', 'facebook' => $company_name]])->user;
     #buyer
     $buyer = Person::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthday' => $faker->dateTimeBetween('-40 years', '-16 years'), 'sex' => 'male', 'user' => ['nickname' => 'antvelbuyer', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/img/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@buyer', 'facebook' => 'buyer']])->user;
     //marked for deleting
     // UserPoints::create([
     //     'user_id' => $buyer->id,
     //     'action_type_id' => 6,
     //     'source_id' => 1,
     //     'points' => 100000,
     // ]);
     // UserAddress::create([
     //     'user_id'=>$buyer->id,
     //     'default'=>1,
     //     'address'=>[
     //         'line1'=>$faker->streetAddress,
     //         'line2'=>$faker->streetAddress,
     //         'phone'=>$faker->phoneNumber,
     //         'name_contact'=>$faker->streetName,
     //         'zipcode'=>$faker->postcode,
     //         'city'=>$faker->city,
     //         'country'=>$faker->country,
     //         'state'=>$faker->state,
     //     ]
     // ]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('businesses', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name', 50);
         //The name of the business
         $table->string('contact', 50);
         //The name of our contact at the business
         $table->string('email', 50)->nullable();
         //Email address of the contact
         //Address fields
         $table->string('line_1', 50);
         $table->string('line_2', 50)->nullable();
         $table->string('line_3', 50)->nullable();
         $table->string('city', 50);
         $table->string('state', 50);
         $table->smallInteger('postcode');
         //4 digits
         $table->softDeletes();
         $table->timestamps();
     });
     //Add our default data we will use for testing
     \App\Business::create(['name' => 'SallySally', 'contact' => 'Sally Test', 'email' => '*****@*****.**', 'line_1' => '1 Test St', 'city' => 'Perth', 'state' => 'Western Australia', 'postcode' => 6000]);
 }
Exemplo n.º 19
0
 public function run()
 {
     $faker = Faker::create();
     $user = Person::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthday' => $faker->dateTimeBetween('-40 years', '-16 years'), 'sex' => $faker->randomElement(['male', 'female']), 'user' => ['nickname' => 'seededuser', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@' . $faker->userName, 'facebook' => $faker->userName]])->user;
     for ($j = 0; $j < 2; $j++) {
         $userPoints = UserPoints::create(['user_id' => $user->id, 'action_type_id' => 6, 'source_id' => 1, 'points' => 10000]);
     }
     $userAddress = Address::create(['user_id' => $user->id, 'default' => 1, 'line1' => $faker->streetAddress, 'line2' => $faker->streetAddress, 'phone' => $faker->phoneNumber, 'name_contact' => $faker->streetName, 'zipcode' => $faker->postcode, 'city' => $faker->city, 'country' => $faker->country, 'state' => $faker->state]);
     $company_name = 'seededinc_inc';
     $enterprise = Business::create(['business_name' => $company_name, 'creation_date' => $faker->date(), 'local_phone' => $faker->phoneNumber, 'user' => ['nickname' => 'seededinc', 'email' => '*****@*****.**', 'password' => Hash::make('123456'), 'pic_url' => '/pt-default/' . $faker->numberBetween(1, 20) . '.jpg', 'twitter' => '@' . $company_name, 'facebook' => $company_name]])->user;
     $catforseed = Category::where('type', 'store')->first();
     $seededProduct = Product::create(['category_id' => $catforseed->id, 'user_id' => '3', 'name' => 'My Seeded Product', 'description' => $faker->text(90), 'price' => $faker->randomNumber(2), 'stock' => 100, 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'features' => json_encode(["images" => ['/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg'], "weight" => $faker->numberBetween(10, 150) . ' ' . $faker->randomElement(["Mg", "Gr", "Kg", "Oz", "Lb"]), "dimensions" => $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' ' . $faker->randomElement(["inch", "mm", "cm"]), "color" => $faker->safeColorName]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'low_stock' => $faker->randomElement([5, 10, 15]), 'rate_val' => '3', 'rate_count' => '5', 'tags' => $faker->word . ',' . $faker->word . ',' . $faker->word]);
     for ($j = 0; $j < 5; $j++) {
         Order::create(['user_id' => $user->id, 'seller_id' => '3', 'address_id' => $userAddress->id, 'status' => 'closed', 'type' => 'order', 'description' => '', 'seller_id' => $enterprise->id, 'end_date' => $faker->dateTime(), 'detail' => ['product_id' => $seededProduct->id, 'price' => $seededProduct->price, 'quantity' => '1', 'delivery_date' => $faker->dateTime(), 'rate' => $faker->numberBetween(1, 5), 'rate_comment' => $faker->text(90)]]);
     }
     $seededProduct2 = Product::create(['category_id' => $catforseed->id, 'user_id' => '3', 'name' => 'Another Seeded Product', 'description' => $faker->text(90), 'price' => $faker->randomNumber(2), 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'stock' => 100, 'features' => json_encode(["images" => ['/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg'], "weight" => $faker->numberBetween(10, 150) . ' ' . $faker->randomElement(["Mg", "Gr", "Kg", "Oz", "Lb"]), "dimensions" => $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' ' . $faker->randomElement(["inch", "mm", "cm"]), "color" => $faker->safeColorName]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'low_stock' => $faker->randomElement([5, 10, 15]), 'rate_val' => '4', 'rate_count' => '5', 'tags' => $faker->word . ',' . $faker->word . ',' . $faker->word]);
     $seededProduct3 = Product::create(['category_id' => $catforseed->id, 'user_id' => '3', 'name' => 'More on Seeded Product', 'description' => $faker->text(90), 'price' => $faker->randomNumber(2), 'stock' => 100, 'brand' => $faker->randomElement(['Apple', 'Gigabyte', 'Microsoft', 'Google. Inc', 'Samsung', 'Lg']), 'features' => json_encode(["images" => ['/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg', '/img/pt-default/' . $faker->numberBetween(1, 330) . '.jpg'], "weight" => $faker->numberBetween(10, 150) . ' ' . $faker->randomElement(["Mg", "Gr", "Kg", "Oz", "Lb"]), "dimensions" => $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' X ' . $faker->numberBetween(1, 30) . ' ' . $faker->randomElement(["inch", "mm", "cm"]), "color" => $faker->safeColorName]), 'condition' => $faker->randomElement(['new', 'refurbished', 'used']), 'low_stock' => $faker->randomElement([5, 10, 15]), 'rate_val' => '4', 'rate_count' => '5', 'tags' => $faker->word . ',' . $faker->word . ',' . $faker->word]);
     //Creates closed orders for rates and mails
     for ($j = 0; $j < 5; $j++) {
         Order::create(['user_id' => $user->id, 'seller_id' => '3', 'address_id' => $userAddress->id, 'status' => 'closed', 'type' => 'order', 'description' => '', 'seller_id' => $enterprise->id, 'end_date' => $faker->dateTime(), 'details' => [['product_id' => $seededProduct->id, 'price' => $seededProduct->price, 'quantity' => '1', 'delivery_date' => $faker->dateTime()], ['product_id' => $seededProduct2->id, 'price' => $seededProduct2->price, 'quantity' => '1', 'delivery_date' => $faker->dateTime()], ['product_id' => $seededProduct3->id, 'price' => $seededProduct3->price, 'quantity' => '1', 'delivery_date' => $faker->dateTime()]]]);
     }
     //Create an open order to test notices
     Order::create(['user_id' => $user->id, 'seller_id' => '3', 'status' => 'open', 'type' => 'order', 'description' => '', 'seller_id' => $enterprise->id, 'address_id' => $userAddress->id, 'details' => [['product_id' => $seededProduct->id, 'price' => $seededProduct->price, 'quantity' => '3']]]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Business::destroy($id);
     return redirect('/admin/business');
 }
Exemplo n.º 21
0
 private function putUserGuestContactOf(Contact $contact, Business $business)
 {
     $business->contacts()->save($contact);
 }
Exemplo n.º 22
0
 public function area($slug)
 {
     $filter = "Average Credit Period";
     $nature = $slug;
     $ids = [];
     $users = Business::where('service_areas', 'LIKE', '%' . $slug . '%')->get();
     foreach ($users as $user) {
         $ids[$user->user_id] = $user->user_id;
     }
     $products = Product::whereIn('user_id', $ids)->paginate(12);
     return view('search.search', compact('products', 'nature', 'filter'));
     /*if($slug==='local_only'){
           $products = Product::paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }
       if($slug==='country_wide'){
           $users = Business::where('service_areas', '=', $slug)->get();
           foreach ($users as $user) {
               $ids[$user->user_id] = $user->user_id;
           }
           $products = Product::whereIn('user_id', $ids)->paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }
       if($slug==='abroad'){
           $users = Business::where('service_areas', '=', $slug)->get();
           foreach ($users as $user) {
               $ids[$user->user_id] = $user->user_id;
           }
           $products = Product::whereIn('user_id', $ids)->paginate(12);
           return view('search.search', compact('products', 'nature','filter'));
       }*/
 }
Exemplo n.º 23
0
 /**
  * get List
  *
  * @return Response Rendered view of all existing Businesses
  */
 public function getList()
 {
     $this->log->info('BusinessController: getList');
     $businesses = Business::all();
     return view('user.businesses.index', compact('businesses'));
 }
 public function dashboard()
 {
     $businesses = Business::all();
     $page = "Tableau de bord";
     return view('admin.index', compact('businesses', 'page'));
 }
Exemplo n.º 25
0
 /**
  * get Index
  *
  * @param  Business $business Business to get agenda
  * @return Response           Rendered view of Business agenda
  */
 public function getIndex(Business $business)
 {
     $this->log->info("BusinessAgendaController: getIndex: businessId:{$business->id}");
     $appointments = $business->bookings()->with('contact')->with('business')->with('service')->unserved()->orderBy('start_at')->get();
     return view('manager.businesses.appointments.' . $business->strategy . '.index', compact('business', 'appointments'));
 }
Exemplo n.º 26
0
 /**
  * Display a loggedin user's business ourFeeds.
  *
  * @return Response
  */
 public function ourFeed($id)
 {
     //all users
     $user = User::where('userName', $id)->first();
     if (empty($user)) {
         return redirect()->back();
     }
     $userDetail = UserDetail::where('userId', $user->id)->first();
     $business = Business::find($userDetail->businessId);
     if (empty($business)) {
         return redirect('/user/' . $user->userName . '/profile');
     }
     $business = (object) array_merge($user->toArray(), $userDetail->toArray(), $business->toArray());
     return view('business.our-feed')->withBusiness($business);
 }
Exemplo n.º 27
0
 public function rateSeller(Request $request)
 {
     $order_id = $request->get('order_id');
     $seller_rate = $request->get('seller_rate');
     $seller_comment = $request->get('seller_comment');
     $user = \Auth::user();
     if ($user) {
         $order = Order::where('id', $order_id)->where('user_id', $user->id)->first();
         if ($order && $order->rate == '') {
             $seller = Business::where('user_id', $order->seller_id)->first();
             $seller_old_rate_val = $seller->rate_val ?: 0;
             $seller_old_rate_count = $seller->rate_count ?: 0;
             //Checks if the order has already been rated by the user
             if ($seller_old_rate_count == 0) {
                 $seller->rate_val = $seller_rate;
                 $seller->rate_count = 1;
             } else {
                 //Checks if the new value should add to the rates or not
                 if ($order->rate) {
                     if ($seller_old_rate_val > $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val - ($seller_old_rate_val - $seller_rate) / $seller_old_rate_count;
                     }
                     if ($seller_old_rate_val < $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val + ($seller_rate - $seller_old_rate_val) / $seller_old_rate_count;
                     }
                 } else {
                     if ($seller_old_rate_val > $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val - ($seller_old_rate_val - $seller_rate) / ($seller_old_rate_count + 1);
                     }
                     if ($seller_old_rate_val < $seller_rate) {
                         $seller->rate_val = $seller_old_rate_val + ($seller_rate - $seller_old_rate_val) / ($seller_old_rate_count + 1);
                     }
                     $seller->rate_count = $seller_old_rate_count + 1;
                 }
             }
             $seller_user = User::find($order->seller_id);
             $email = $seller_user->email;
             $mail_subject = trans('email.order_rated.subject');
             $data = ['order_id' => $order_id, 'subject' => $mail_subject, 'email_message' => $mail_subject, 'email' => $email];
             Mail::queue('emails.order_rated', $data, function ($message) use($user, $data) {
                 $message->to($data['email'])->subject($data['subject']);
             });
             $order->rate = $seller_rate;
             $order->rate_comment = $seller_comment;
             $order->save();
             $seller->save();
             $noticeType = trim($seller_comment) != '' ? '3' : '14';
             Notice::create(['user_id' => $seller->user_id, 'sender_id' => $user->id, 'action_type_id' => 14, 'source_id' => $order->id, 'status' => 'new']);
             return \Response::json(array('success' => true, 'message' => trans('store.order_rate_view.http_messages.success'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
         } else {
             return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_order'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
         }
     } else {
         return \Response::json(array('success' => false, 'message' => trans('store.order_rate_view.http_messages.no_user'), 'order_id' => $order_id, 'seller_rate' => $seller_rate), 200);
     }
 }
Exemplo n.º 28
0
 /**
  * Guarda los cambio del usuario.
  *
  * @param Request $request peticion
  *
  * @return Laravel Redirect
  */
 public function saveProfile(Request $request)
 {
     $user = \Auth::user();
     $v = \Validator::make($request->all(), $this->form_rules);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     }
     //user update
     \Session::flash('message', trans('user.saved'));
     $user->fill($request->all());
     $user->pic_url = $request->get('pic_url');
     $user->password = bcrypt($request->get('password'));
     $user->save();
     //bussiness update
     if ($request->get('business_name') !== null && trim($request->get('business_name')) != '') {
         $business = Business::find($user->id);
         $business->business_name = $request->get('business_name');
         $business->save();
     }
     //person update
     if ($request->get('first_name') !== null && trim($request->get('first_name')) != '') {
         $person = Person::find($user->id);
         $person->first_name = $request->get('first_name');
         $person->last_name = $request->get('last_name');
         $person->birthday = $request->get('birthday');
         $person->sex = $request->get('sex');
         $person->save();
     }
     return redirect()->back();
 }
 public function create()
 {
     $business = Business::paginate(5);
     return view('investment/create', compact('business'));
 }
 public function delete($id)
 {
     $business = Business::findOrFail($id);
     $business->delete();
     return redirect('kohteet');
 }