Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($data = Input::all(), service::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     service::create($data);
     return Redirect::route('admin.services.index');
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     $names = new ArrayIterator(array('names' => 'New Permanent Electric Connection', 'New Temporary/Permanent Electric Connection', 'New Permanent Electric Connection Through Panel', 'Temporary Electric Connection', 'New Meter Testing', 'Existing Meter Testing', 'Replace Meter/Meterboard', 'Approve Meter', 'Relocate Existing Meterboard', 'Relocate Existing Meter to Panel', 'Panel Modification Testing', 'Relocate SDB', 'Relocate MDB', 'Temporary Disconnection', 'Permanent Disconnection', 'Reconnection', 'Replace Cable', 'Cable Details and Price'));
     $i = 1;
     foreach ($names as $name) {
         $cat = 1;
         if ($i >= 5) {
             $cat = 2;
         } elseif ($i >= 12) {
             $cat = 3;
         } elseif ($i >= 14) {
             $cat = 4;
         }
         \App\service::create(['name' => $name, 'desc' => $faker->paragraph, 'service_category_id' => $cat, 'icon' => $faker->url, 'link' => $faker->url, 'featured' => rand(0, 1), 'order' => $i, 'status' => true]);
         $i++;
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(servicesRequest $request)
 {
     $important = 'true';
     if (empty($request->input('important'))) {
         $important = 'false';
     }
     $name = rand(1000, 9999);
     $request->file('pic1')->move('images/services/', $name . '.png');
     $service = service::create(['title' => $request->input('title'), 'desc' => $request->input('desc'), 'pic' => '/images/services/' . $name . '.png', 'important' => $important]);
     servicePic::create(['service_id' => $service->id, 'pic' => 'images/services/' . $name . '.png']);
     $count = 1;
     foreach ($request->file() as $s) {
         if ($count != 1) {
             $name = rand(1000, 9999);
             $s->move('images/services/', $name . '.png');
             servicePic::create(['service_id' => $service->id, 'pic' => 'images/services/' . $name . '.png']);
         }
         $count++;
     }
     return redirect('services/' . $service->id);
 }