Ejemplo n.º 1
0
 /**
  * Delete a detail
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Request $request, $id)
 {
     $event = Event::find($request->input('event'));
     $detail = Detail::find($id);
     if ($detail && $event->user_id == $request->user()->id) {
         $detail->delete();
         //Flash a message to the user
         \Flash::success('Detail deleted');
     } else {
         //Flash a message to the user
         \Flash::danger('Sorry, permission denied');
     }
     $event = Event::findOrFail($request->input('event'));
     //Redirect back to the admin page
     return redirect(action('EventsController@admin', $event->slug));
 }
Ejemplo n.º 2
0
 public function stock()
 {
     $tran = $this->data->tran;
     $inches = $this->data->inch;
     $defaulInch = 15;
     $storages = Detail::group();
     $sells = Sell::group();
     $tires = Tire::defaultInch($defaulInch);
     $defaultSpec = $tires->first()->spec;
     $details = Detail::allGroup($defaultSpec);
     foreach ($details as $detail) {
         $sales = Sell::pairGroup($detail);
         $salesQ = empty($sales) ? 0 : $sales->Q;
         $detailQ = $detail->Q;
         $detail->Q = $detailQ - $salesQ;
     }
     foreach ($storages as $storage) {
         $storageCom[$storage->location][$storage->state] = $storage->Q;
     }
     foreach ($sells as $sell) {
         $sellCom[$sell->location][$sell->state] = $sell->Q;
     }
     //$array = [ 'home'=>['a','b'], 'next'=>'b', 'ware'=> 'b'];
     $array = ['home' => ['a', 'b']];
     foreach ($array as $k1 => $v1) {
         if (is_array($array[$k1])) {
             foreach ($array[$k1] as $v2) {
                 isset($storageCom[$k1][$v2]) or $storageCom[$k1][$v2] = 0;
                 isset($sellCom[$k1][$v2]) or $sellCom[$k1][$v2] = 0;
                 $comString = $k1 . strtoupper($v2);
                 $comStorage[$comString] = $storageCom[$k1][$v2] - $sellCom[$k1][$v2];
             }
         } else {
             isset($storageCom[$k1][$v1]) or $storageCom[$k1][$v1] = 0;
             $comString = $k1 . strtoupper($v1);
             $comStorage[$comString] = $storageCom[$k1][$v1] - $sellCom[$k1][$v1];
         }
     }
     $aCompact = compact('inches', 'comStorage', 'tires', 'details', 'tran');
     return view('f.stock', $aCompact);
 }
Ejemplo n.º 3
0
 public function postSearchResult()
 {
     if ($_POST['q']) {
         $tran = Data::getTran();
         !isset($_POST['state']) and $_POST['state'] = null;
         $data = [$_POST['q'], $_POST['state']];
         $details = Detail::allGroup($data);
         foreach ($details as $detail) {
             $sales = Sell::pairGroup($detail)->first();
             $salesQ = empty($sales) ? 0 : $sales->Q;
             $detailQ = $detail->Q;
             $detail->Q = $detailQ - $salesQ;
         }
         $results = trRows($details, $tran, $grids = 3);
         echo $results;
     } else {
         echo '無資料';
     }
 }
Ejemplo n.º 4
0
 /**
  * Change the detail for a competition (after the user has entered the event)
  */
 public function changeDetail(Request $request, $entry_id)
 {
     $data = $request->all();
     $entry = Entry::findOrFail($entry_id);
     $entry['detail_id'] = $data['newDetail'];
     $entry->save();
     $detail = Detail::findOrFail($data['newDetail']);
     \Flash::success("No problem! You're detail has been changed to " . $detail->dateTime->toDateTimeString());
     return redirect(action('PagesController@userEntries'));
 }
Ejemplo n.º 5
0
 /**
  * Export list of competitors and competitions
  */
 public function export($type, $id)
 {
     $header = array('Competitor name', 'ID', 'Email', 'Club', 'Home Country');
     if ($type == 'competitors') {
         $event = Event::findOrFail($id);
         $entries = $event->entries()->get()->sortBy('user_lastname');
         $competitor_ids = $entries->pluck('user_id')->unique();
         $competitions = $event->competitions()->get();
         $header = array();
         foreach ($competitions as $competition) {
             $header[] = $competition->name;
         }
         $sheetdata = array($header);
         foreach ($competitor_ids as $competitor_id) {
             $competitorEntries = $event->entries()->get()->where('user_id', $competitor_id);
             $thisCompetitor = User::findOrFail($competitor_id);
             $name = $thisCompetitor->lastname . ", " . $thisCompetitor->firstname;
             $row = array($name);
             foreach ($competitions as $competition) {
                 $entered_competition_ids = array();
                 foreach ($competitorEntries as $entry) {
                     $entered_competition_ids[] = $entry->competition_id;
                 }
                 if (in_array($competition->id, $entered_competition_ids)) {
                     $row[] = "Entered";
                 } else {
                     $row[] = "";
                 }
             }
             $sheetdata[] = $row;
         }
         Excel::create('competitors', function ($excel) use($sheetdata) {
             $excel->setTitle('Competitors List');
             $excel->setCreator('Foresight Entries');
             $excel->setCompany('Foresightentries.com');
             $excel->setDescription('Competitors list');
             // Create the sheet
             $excel->sheet('Competitors', function ($sheet) use($sheetdata) {
                 $sheet->fromArray($sheetdata);
             });
         })->export('xlsx');
         return redirect()->back();
     }
     // Download ALL the data in one mega spreadsheet (for the overview tab)
     if ($type == 'event') {
         $event = Event::findOrFail($id);
         $competitions = $event->competitions()->get();
         $megaheader = $header;
         $sheets = array();
         //Sheet showing all competitors, their entries, their answers, extras and how much paid
         // -- HEADERS --
         // ---- competitions --
         foreach ($event->competitions()->get() as $competition) {
             $megaheader[] = $competition->name;
         }
         // ---- questions --
         foreach ($event->questions()->get() as $question) {
             $megaheader[] = $question->question;
         }
         // ---- extras --
         foreach ($event->extras()->get() as $extra) {
             //fill in once extras is worked out
         }
         // ---- financial --
         $megaheader[] = "Entry fees (total)";
         //MEGASHEET INITIALISE
         $megasheet = array($megaheader);
         // DATA ENTRY TO MEGASHEET
         $entries = $event->entries()->get()->sortBy('user_lastname');
         $competitor_ids = $entries->pluck('user_id')->unique();
         foreach ($competitor_ids as $competitor_id) {
             $thisCompetitor = User::findOrFail($competitor_id);
             $row = array($thisCompetitor->firstname . " " . $thisCompetitor->lastname, $thisCompetitor->id + 1000, $thisCompetitor->email, $thisCompetitor->club, $thisCompetitor->homeCountry);
             // -- ENTRIES --
             $competitorEntries = $event->entries()->get()->where('user_id', $competitor_id);
             $competitorEntriesCompetitionIDs = array();
             foreach ($competitorEntries as $entry) {
                 $competitorEntriesCompetitionIDs[$entry->competition_id] = $entry->competition_id;
             }
             foreach ($event->competitions()->get() as $competition) {
                 // if entry->competition_id exists in $competitorEntries then entered row, else empty row.
                 if (key_exists($competition->id, $competitorEntriesCompetitionIDs)) {
                     $row[] = "x";
                 } else {
                     $row[] = " ";
                 }
             }
             // -- ANSWERS --
             $competitorAnswers = $event->answers()->get()->where('competitor_id', $competitor_id);
             $competitorAnsweredQuestionIDs = array();
             foreach ($competitorAnswers as $answer) {
                 $competitorAnsweredQuestionIDs[$answer->question_id] = $answer->question_id;
             }
             //@TODO: this needs to be tested with a user who has answered questions. 5/7/16
             foreach ($competitorAnswers as $competitorAnswer) {
                 if (key_exists($competitorAnswer->question_id, $competitorAnsweredQuestionIDs)) {
                     $row[] = $competitorAnswer->answer;
                 } else {
                     $row[] = "N/A";
                 }
             }
             // -- EXTRAS --
             //@TODO: fill in once extras is worked out
             // -- ENTRY FEES TOTAL --
             $row[] = "subtotal here (£)";
             // Add the row to the megasheet
             $megasheet[] = $row;
         }
         //Add the megasheet to sheets
         $sheets["Competitors"] = $megasheet;
         //Sheet for each competition and detail with the entries
         foreach ($competitions as $competition) {
             $details = $competition->details()->get();
             foreach ($details as $detail) {
                 $entries = $detail->entries()->get()->sortBy('user_lastname');
                 $sheetdata = array($header);
                 $competitor_ids = $entries->pluck('user_id')->unique();
                 foreach ($competitor_ids as $competitor_id) {
                     $competitor = User::findOrFail($competitor_id);
                     $row = array($competitor->firstname . " " . $competitor->lastname, $competitor->id + 1000, $competitor->email, $competitor->club, $competitor->homeCountry);
                     $sheetdata[] = $row;
                 }
                 $sheets[$competition->name . "-" . $detail->name] = $sheetdata;
             }
         }
         Excel::create($event->name, function ($excel) use($sheets, $competitions) {
             $excel->setTitle('Competitors');
             $excel->setCreator('Foresight Entries');
             $excel->setCompany('ForesightEntries.com');
             $excel->setDescription('Competitors List');
             $infosheet = $sheets["Competitors"];
             $excel->sheet('Competitors', function ($sheet) use($infosheet) {
                 $sheet->fromArray($infosheet);
             });
             foreach ($competitions as $competition) {
                 $details = $competition->details()->get();
                 foreach ($details as $detail) {
                     $sheet = $sheets[$competition->name . '-' . $detail->name];
                     $excel->sheet($competition->name . '-' . $detail->name, function ($thissheet) use($sheet) {
                         $thissheet->fromArray($sheet);
                     });
                 }
             }
         })->export('xlsx');
         return redirect()->back();
     }
     if ($type == 'competition') {
         $competition = Competition::findOrFail($id);
         $details = $competition->details()->get();
         $sheets = array();
         foreach ($details as $detail) {
             $entries = $detail->entries()->get()->sortBy('user_lastname');
             $sheetdata = array($header);
             $competitor_ids = $entries->pluck('user_id')->unique();
             foreach ($competitor_ids as $competitor_id) {
                 $competitor = User::findOrFail($competitor_id);
                 $row = array($competitor->firstname . " " . $competitor->lastname, $competitor->id + 1000, $competitor->email, $competitor->club, $competitor->homeCountry);
                 $sheetdata[] = $row;
             }
             $sheets[$detail->name] = $sheetdata;
         }
         Excel::create($competition->name, function ($excel) use($sheets, $details) {
             $excel->setTitle('Competitors');
             $excel->setCreator('Foresight Entries');
             $excel->setCompany('ForesightEntries.com');
             $excel->setDescription('Competitors List');
             foreach ($details as $detail) {
                 $sheet = $sheets[$detail->name];
                 $excel->sheet($detail->name, function ($thissheet) use($sheet) {
                     $thissheet->fromArray($sheet);
                 });
             }
         })->export('xlsx');
         return redirect()->back();
     }
     if ($type == 'detail') {
         $detail = Detail::findOrFail($id);
         $entries = $detail->entries()->get()->sortBy('user_lastname');
         $sheetdata = array($header);
         $competitor_ids = $entries->pluck('user_id')->unique();
         foreach ($competitor_ids as $competitor_id) {
             $competitor = User::findOrFail($competitor_id);
             $row = array($competitor->firstname . " " . $competitor->lastname, $competitor->id + 1000, $competitor->email, $competitor->club, $competitor->homeCountry);
             $sheetdata[] = $row;
         }
         Excel::create($detail->competition()->first()->name . "-" . $detail->name, function ($excel) use($sheetdata) {
             $excel->setTitle('Competitors');
             $excel->setCreator("Foresight Entries");
             $excel->setCompany("ForesightEntries.com");
             $excel->setDescription("Competitors List");
             $excel->sheet('Competitors', function ($sheet) use($sheetdata) {
                 $sheet->fromArray($sheetdata);
             });
         })->export('xlsx');
         return redirect()->back();
     }
     if ($type == 'competitor_entries') {
         $event = Event::findOrFail($id);
         $entries = $event->entries()->get()->sortBy('user_lastname');
         $competitor_ids = $entries->pluck('user_id')->unique();
         //Add competition names to the header
         foreach ($event->competitions()->get() as $competition) {
             $header[] = $competition->name;
         }
         $sheetdata = array($header);
         foreach ($competitor_ids as $competitor_id) {
             $competitorEntries = $event->entries()->get()->where('user_id', $competitor_id);
             $competitorEntriesCompetitionIDs = array();
             foreach ($competitorEntries as $entry) {
                 $competitorEntriesCompetitionIDs[$entry->competition_id] = $entry->competition_id;
             }
             $thisCompetitor = User::findOrFail($competitor_id);
             $row = array($thisCompetitor->firstname . " " . $thisCompetitor->lastname, $thisCompetitor->id + 1000, $thisCompetitor->email, $thisCompetitor->club, $thisCompetitor->homeCountry);
             foreach ($event->competitions()->get() as $competition) {
                 // if entry->competition_id exists in $competitorEntries then entered row, else empty row.
                 if (key_exists($competition->id, $competitorEntriesCompetitionIDs)) {
                     $row[] = "x";
                 } else {
                     $row[] = " ";
                 }
             }
             $sheetdata[] = $row;
         }
         Excel::create("Competitor entries", function ($excel) use($sheetdata) {
             $excel->setTitle('Competitor_entries');
             $excel->setCreator("Foresight Entries");
             $excel->setCompany("ForesightEntries.com");
             $excel->setDescription("Competitors List");
             $excel->sheet('Competitor_entries', function ($sheet) use($sheetdata) {
                 $sheet->fromArray($sheetdata);
             });
         })->export('xlsx');
         return redirect()->back();
     }
     if ($type == 'competitor_answers') {
         $event = Event::findOrFail($id);
         $entries = $event->entries()->get()->sortBy('user_lastname');
         $competitors = $entries->pluck('user_id')->unique();
         //Add the questions to the header
         foreach ($event->questions()->get() as $question) {
             $header[] = $question->question;
         }
         $sheetdata = array($header);
         foreach ($competitors as $competitor) {
             $competitorAnswers = $event->answers()->get()->where('competitor_id', $competitor);
             $competitorAnsweredQuestionIDs = array();
             foreach ($competitorAnswers as $answer) {
                 $competitorAnsweredQuestionIDs[$answer->question_id] = $answer->question_id;
             }
             $thisCompetitor = User::findOrFail($competitor);
             $row = array($thisCompetitor->firstname . " " . $thisCompetitor->lastname, $thisCompetitor->id + 1000, $thisCompetitor->email, $thisCompetitor->club, $thisCompetitor->homeCountry);
             //@TODO: this needs to be tested with a user who has answered questions. 5/7/16
             foreach ($competitorAnswers as $competitorAnswer) {
                 if (key_exists($competitorAnswer->question_id, $competitorAnsweredQuestionIDs)) {
                     $row[] = $competitorAnswer->answer;
                 } else {
                     $row[] = "N/A";
                 }
             }
             $sheetdata[] = $row;
         }
         Excel::create("Competitor answers", function ($excel) use($sheetdata) {
             $excel->setTitle('Competitor_answers');
             $excel->setCreator("Foresight Entries");
             $excel->setCompany("ForesightEntries.com");
             $excel->setDescription("Competitor answers");
             $excel->sheet('Competitor_answers', function ($sheet) use($sheetdata) {
                 $sheet->fromArray($sheetdata);
             });
         })->export('xlsx');
         return redirect()->back();
     }
 }
Ejemplo n.º 6
0
 public function postUpdate(GathersPostRequest $request)
 {
     $gather = Gather::find($request->id);
     $gather->name = $request->name;
     $gather->category_id = $request->category_id;
     $gather->code = $request->code;
     $gather->description = $request->description;
     $gather->save();
     foreach ($request->detail as $key => $value) {
         if ($value) {
             $detail = Detail::firstOrCreate(['gather_id' => $gather->id, 'item_id' => $key]);
             $detail->content = $value;
             $detail->save();
         }
     }
     return redirect()->to("gathers");
 }
Ejemplo n.º 7
0
 public function getAutoHomeCategories()
 {
     set_time_limit(0);
     $snoopy = new Snoopy();
     $url = "http://car.autohome.com.cn/baoyang/list_1_33_0_0_0.html";
     //构造抓取URL
     $snoopy->fetch($url);
     preg_match('/id="frame_tree"[\\s\\S]+?<ul>[\\s\\S]+?<\\/ul>/', $snoopy->results, $match);
     print_r($match);
     die;
     $snoopy->results = $match[0];
     preg_match_all('/id="brand_.+?>(\\w+)\\(/', $snoopy->results, $match);
     if (isset($match[0]) && !empty($match[0])) {
         $engines_match = $match[0];
         foreach ($engines_match as $prg_str) {
             preg_match_all('/href="(.+?)"/', $prg_str, $match);
             $all_urls = !empty($all_urls) ? array_merge($all_urls, $match[1]) : $match[1];
         }
     }
     if (!empty($all_urls)) {
         foreach ($all_urls as $url) {
             Detail::firstOrCreate(['autohome_url' => $url, 'brand_id' => $brand->id]);
         }
     }
     echo $brand->name . '-end-<br>';
 }
Ejemplo n.º 8
0
 /**
  * 姹借溅涔嬪淇濆吇鏁版嵁
  * @param Request $request
  */
 public function index(Request $request)
 {
     $validator = Validator::make($request->all(), ['mycar_id' => 'required|integer']);
     if ($validator->fails()) {
         echo json_encode(['status' => 'false', 'msg' => $validator->errors(), 'data' => (object) null]);
         die;
     }
     $mycar_id = Input::get('mycar_id');
     //获取保养ID
     $myCarData = $this->connection->table('my_car')->where('id', $mycar_id)->first();
     if (is_null($myCarData)) {
         echo json_encode(['status' => 'false', 'msg' => 'mycar_id没有被发现', 'data' => (object) null]);
         die;
     }
     $model_slug = $myCarData->model_detail;
     $kilometers = intval($myCarData->mileage * 10000);
     $detail_id = $this->connection->table('foreign_category_autohome')->where('detail_model_slug', $model_slug)->pluck('dmodel_id');
     $maintain_id = CarModel::where('id', $detail_id)->pluck('maintain_id');
     if (is_null($maintain_id)) {
         $year = $myCarData->year;
         $brand_name = $this->connection->table('open_category')->where('slug', $myCarData->brand)->pluck('name');
         $type_name = $this->connection->table('open_category')->where('slug', $myCarData->model)->pluck('name');
         $typeNames[] = $type_name;
         if (strpos($type_name, $brand_name) !== false) {
             $length = strlen($brand_name);
             $typeNames[] = substr($type_name, $length);
         }
         $typeId = $this->connection->table('autohome_types')->whereIn('name', $typeNames)->pluck('id');
         $nearModels = CarModel::select('maintain_id', 'year')->where('type_id', $typeId)->groupBy('year')->get();
         if (count($nearModels) > 0) {
             foreach ($nearModels as $nearModel) {
                 //取最相近同款年份的保养ID
                 if (!isset($minYearAbs) || abs($nearModel->year - $year) < $minYearAbs) {
                     $minYearAbs = $nearModel->year;
                     $maintain_id = $nearModel->maintain_id;
                 }
             }
         }
     }
     //通配
     if (is_null($maintain_id) && $myCarData->eval_price < 50) {
         $maintain_id = $this->commonMaintainId;
     }
     if (is_null($maintain_id)) {
         echo json_encode(['status' => "false", 'msg' => '匹配不到保养信息', 'data' => (object) null]);
         die;
     }
     //保养信息
     $detailInfo = Detail::find($maintain_id);
     $projectInfo = Project::all();
     foreach ($projectInfo as $project) {
         $projectMaps[$project->id] = $project->name;
     }
     //价格
     $priceInfo = DetailProjectPrice::where('detail_id', $maintain_id)->get();
     //价格通配
     if (count($priceInfo) == 0) {
         $priceInfo = DetailProjectPrice::where('detail_id', $this->commonMaintainId)->get();
     }
     foreach ($priceInfo as $pro_price) {
         $priceMaps[$pro_price->project_id] = $pro_price->price;
     }
     //我的车保养记录
     $maintainCarInfo = $this->connection->table('maintain_car_record')->where('mycar_id', $mycar_id)->orderBy('created_at', 'desc')->first();
     $fixKilometers = 0;
     //根据之前的保养里程,修正保养里程
     $current_not_maintain_flag = false;
     //不提醒当次保养过的数据
     if (!is_null($maintainCarInfo) && $maintainCarInfo->kilometers <= $kilometers) {
         $maintainKilometers = $maintainCarInfo->kilometers;
         $fixKilometers = $this->getFixKilometersByLastMaintainData($maintainKilometers, $detailInfo);
         if ($kilometers <= $maintainKilometers + $this->deviationKilometers) {
             $current_not_maintain_flag = true;
         }
     }
     //算出保养区间
     if ($kilometers <= $detailInfo->first_maintain_kilometers + $fixKilometers + $this->deviationKilometers) {
         $section = 0;
     } elseif ($kilometers <= $detailInfo->second_maintain_kilometers + $fixKilometers + $this->deviationKilometers) {
         $section = 1;
     } else {
         $section = ceil(($kilometers - ($detailInfo->second_maintain_kilometers + $fixKilometers + $this->deviationKilometers)) / $detailInfo->maintain_interval_kilometers) + 1;
     }
     if ($current_not_maintain_flag) {
         $section++;
     }
     //距离下次保养里程
     if ($section == 0) {
         $next_kilometers = $detailInfo->first_maintain_kilometers;
         $next_next_kilometers = $detailInfo->second_maintain_kilometers;
     } else {
         $next_kilometers = $detailInfo->second_maintain_kilometers + $detailInfo->maintain_interval_kilometers * ($section - 1);
         $next_next_kilometers = $detailInfo->second_maintain_kilometers + $detailInfo->maintain_interval_kilometers * $section;
     }
     $next['kilometers'] = $next_kilometers + $fixKilometers - $kilometers;
     $next['day'] = max(0, floor($next['kilometers'] / ($this->kilometersPerSection / 180)));
     if (abs($next['kilometers']) > $this->deviationKilometers) {
         $next['need_maintain_immediately'] = false;
     } else {
         $next['need_maintain_immediately'] = true;
     }
     $next['maintain_interval_kilometers'] = $detailInfo->maintain_interval_kilometers;
     //保养数据支持的最高里程数 10000为保留值
     $allSections = DetailSection::where('detail_id', $maintain_id)->get();
     $next['max_kilometers'] = (count($allSections) - 2) * $detailInfo->maintain_interval_kilometers + $detailInfo->second_maintain_kilometers - 10000;
     $sectionInfo = DetailSection::where('detail_id', $maintain_id)->where('section', $section)->first();
     if (!is_null($sectionInfo)) {
         //需要保养项目
         $price = 0;
         $projects_ids = explode(',', $sectionInfo->project_ids);
         foreach ($projects_ids as $projectId) {
             $arr['id'] = $projectId;
             $arr['name'] = $projectMaps[$projectId];
             if (isset($priceMaps[$projectId])) {
                 $price += $priceMaps[$projectId];
             }
             $projects[] = $arr;
         }
         $title = '推荐保养计划: ' . $next_kilometers . '公里保养';
         $maintainData[0] = ['title' => $title, 'price' => $price, 'projects' => $projects];
         //下次需要保养项目
         $another_sectionInfo = DetailSection::where('detail_id', $maintain_id)->where('section', $section + 1)->first();
         if (!is_null($another_sectionInfo)) {
             $another_price = 0;
             $another_projects_ids = explode(',', $another_sectionInfo->project_ids);
             if (!empty($another_projects_ids)) {
                 foreach ($another_projects_ids as $projectId) {
                     $arr['id'] = $projectId;
                     $arr['name'] = $projectMaps[$projectId];
                     if (isset($priceMaps[$projectId])) {
                         $another_price += $priceMaps[$projectId];
                     }
                     $another_projects[] = $arr;
                 }
             }
             $another_title = '保养计划: ' . $next_next_kilometers . '公里保养';
             $maintainData[1] = ['title' => $another_title, 'price' => $another_price, 'projects' => $another_projects];
         }
     } else {
         echo json_encode(['status' => "false", 'msg' => '无法得到保养项目信息', 'data' => (object) null]);
         die;
     }
     echo json_encode(['status' => "success", 'msg' => '返回成功', 'data' => ['next' => $next, 'maintain' => $maintainData]]);
 }
Ejemplo n.º 9
0
 public function newshop(Request $request)
 {
     //
     $destinationPath = "uploadfiles/";
     $id = Auth::user()->id;
     $cname = $request->input('cname');
     $type = $request->input('type');
     $ctype = $request->input('ctype');
     $file = $request->file('logo');
     $cnumber = $request->input('cnumber');
     $caddress = $request->input('caddress');
     $ctel = $request->input('ctel');
     if (empty($file)) {
         $fName = "all.jpg";
     } else {
         if ($file->isValid()) {
             $fileName = $file->getClientOriginalName();
             $fileName = substr(md5($fileName), -4) . time();
             $entension = $file->getClientOriginalExtension();
             $fName = $fileName . '.' . $entension;
             $file->move($destinationPath, $fName);
         } else {
             $fName = "all.jpg";
         }
     }
     // Request::file('photo')->move($destinationPath);
     $detail = new Detail();
     $detail->cname = $cname;
     $detail->type = $type;
     $detail->ctype = $ctype;
     $detail->image = $fName;
     $detail->cnumber = $cnumber;
     $detail->caddress = $caddress;
     $detail->ctel = $ctel;
     $detail->user_id = $id;
     $detail->save();
     $cid = DB::table('details')->where('user_id', $id)->pluck('id');
     return view('center.addcontract');
 }