Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['name' => 'required|unique:papers', 'size' => 'required|unique:papers']);
     if ($validator->fails()) {
         if ($request->ajax()) {
             return response()->json($validator->messages());
             exit;
         } else {
             return \Redirect::back()->withErrors($validator)->withInput();
         }
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $paper = new Paper();
     foreach ($all_request as $key => $value) {
         $paper->{$key} = $value;
     }
     $paper->save();
     $papers = Paper::all();
     if ($request->ajax()) {
         if ($papers) {
             foreach ($papers as $paper) {
                 echo "\n                        <tr>\n                            <td>{$paper->id}</td>\n                            <td>{$paper->name}</td>\n                            <td>{$paper->description}</td>\n                            <td>{$paper->dimension}</td>\n                            <td>{$paper->unit}</td>\n\n                            <td><button class='edtPaperLink btn-primary' cid='{$paper->id}' cname='{$paper->name}' cdescription='{$paper->description}' cdimension='{$paper->dimension}' cunit='{$paper->unit}'><span  class='glyphicon glyphicon-pencil'></span></button></td>\n                            <td><button class='btn-danger'  data-target='#myModalPaperEdit' data-toggle='modal'><span  class='glyphicon glyphicon-trash'></span></button></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     }
     return View("settings.paper", ["companies" => Company::all(), 'papers' => $papers, 'title' => 'Job Papers Setting']);
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     //
     $input = $request->all();
     $validator = Validator::make($input, ['price' => 'required', 'job_type' => 'required', 'job_id' => 'required', 'paper_id' => 'required']);
     if ($validator->fails()) {
         return \Redirect::back()->withErrors($validator)->withInput();
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $price = Price::find($id);
     $papers = Paper::all();
     $jobs = Job::all();
     foreach ($all_request as $key => $value) {
         $price->{$key} = $value;
     }
     $price->update();
     $prices = Price::all();
     if ($request->ajax()) {
         if ($prices) {
             foreach ($prices as $price) {
                 echo "\n                        <tr>\n                            <td>{$price->id}</td>\n                            <td>";
                 foreach ($papers as $paper) {
                     if ($paper->id == $price->paper_id) {
                         $paperid = $paper->name;
                         echo $paper->name . ", " . $paper->size;
                     }
                 }
                 echo " </td>\n                            <td>";
                 foreach ($jobs as $job) {
                     if ($job->id == $price->job_id) {
                         $jobid = $job->name;
                         echo $job->name;
                     }
                 }
                 echo "</td>\n                            <td>{$price->job_type}</td>\n                            <td>{$price->price}</td>\n                            <td><button class='edtPriceLink btn-primary' cpaperid='{$paperid}' cjobtype='{$price->job_type}' cid='{$price->id}' cjobid='{$price->job_id}' cprice='{$price->price}'><span  class='glyphicon glyphicon-pencil'></span></button></td>\n                            <td><button class='btn-danger'  data-target='#myModalPaperEdit' data-toggle='modal'><span  class='glyphicon glyphicon-trash'></span></button></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     } else {
         try {
             if ($price->update()) {
                 \Session::flash("success_message", "New Price Record Updated Successfully");
                 return \Redirect::back();
             }
         } catch (\Illuminate\Database\QueryException $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         } catch (\PDOException $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         } catch (\Exception $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         }
     }
     return View("settings.priceedit", ['jobs' => $jobs, 'papers' => $papers, 'title' => 'Job Setting']);
 }
Exemplo n.º 3
0
 public function postPrice(Request $request)
 {
     array_forget($request, "_token");
     $all_request = $request->all();
     $price = new Price();
     foreach ($all_request as $key => $value) {
         $price->{$key} = $value;
     }
     $price->save();
     $prices = Price::all();
     if ($request->ajax()) {
         if ($prices) {
             foreach ($prices as $price) {
                 echo "\n                       <tr>\n                            <td>{$price->id}</td>\n                            <td>{$price->name}</td>\n\n                            <td>{$price->description}</td>\n                            <td>{$price->created_at}</td>\n                            <td>{$price->updated_at}</td>\n                            <td></td>\n                            <td></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     }
     return View("settings.price", ['prices' => $prices, 'papers' => Paper::all(), 'jobs' => Job::all(), 'title' => 'Job Price Setting']);
 }
Exemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\View\View
  */
 public function index(Paper $model)
 {
     $papers = $model->all();
     return view('paper.index', compact('papers'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $papers = Paper::all();
     return view('admin.paper.base', ['papers' => $papers]);
 }
 public function compose(View $view)
 {
     $examList = array('' => 'Select a exam date') + DB::table('sittings')->select(DB::raw('concat (month," / ",year) as sitting,id'))->lists('sitting', 'id');
     $view->with('methodList', \App\Method::all())->with('levelList', \App\Level::all())->with('paperList', \App\Paper::all())->with('centreList', \App\Centre::all())->with('elementList', \App\Element::all())->with('examList', $examList);
 }