當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Branch::save方法代碼示例

本文整理匯總了PHP中app\Branch::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Branch::save方法的具體用法?PHP Branch::save怎麽用?PHP Branch::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Branch的用法示例。


在下文中一共展示了Branch::save方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * 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|min:5|unique:branches', 'email' => 'required|min:5|unique:branches', 'city' => 'required', 'phone' => 'required']);
     if ($validator->fails()) {
         if ($request->ajax()) {
             return response()->json($validator->messages());
         } else {
             return \Redirect::back()->withErrors($validator)->withInput();
         }
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $branch = new Branch();
     foreach ($all_request as $key => $value) {
         $branch->{$key} = $value;
     }
     if ($request->ajax()) {
         if ($branch->save()) {
             return response()->json("Site Successfully Created");
         } else {
             return response()->json("Unexpected Error Record Could not be saved");
         }
     } else {
         //if post  is not AJAX
         if ($branch->save()) {
             \Session::flash("success_message", "Site Successfully Created");
             return Redirect::back();
         } else {
             \Session::flash("error_message", "Unexpected Error Role was not created");
             return Redirect::back();
         }
     }
 }
開發者ID:runningjack,項目名稱:lexmark2,代碼行數:39,代碼來源:BranchController.php

示例2: addNew

 public static function addNew(Request $request)
 {
     $branch = new Branch();
     $branch->name = $request->input('name');
     $branch->phone = $request->input('phone');
     $branch->fax = $request->input('fax');
     $branch->email = $request->input('email');
     $branch->save();
     return $branch;
 }
開發者ID:VoodooPrawn,項目名稱:finest,代碼行數:10,代碼來源:Branch.php

示例3: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $data = $request->only('branchName', 'branchLocation');
     //return $data;
     $branch = new Branch();
     $branch->name = $data['branchName'];
     $branch->location = $data['branchLocation'];
     $branch->delivery_charge = $request['delivery_charge'];
     if ($branch->save()) {
         $returnData = array('status' => 'ok', 'message' => 'Branch created', 'branch' => $branch, 'code' => 200);
         return Response::json($returnData, 200);
     } else {
         $returnData = array('status' => 'fail', 'message' => 'Branch not created', 'code' => 500);
         return Response::json($returnData, 200);
     }
 }
開發者ID:premsingh4github,項目名稱:edealer,代碼行數:21,代碼來源:BranchController.php

示例4: store

 /**
  * 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', 'city' => 'required']);
     if ($validator->fails()) {
         return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => implode($validator->errors()->all(), '<br>'))));
     }
     $branch = new Branch();
     $branch->name = $request->name;
     // find province, country
     $city = \App\City::where('city_name', $request->city)->first();
     $branch->city = $request->city;
     $branch->province = $city->province->province_name;
     $branch->country = $city->province->country->nicename;
     $branch->manager = $request->manager;
     $branch->save();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved')));
 }
開發者ID:borislemke,項目名稱:kbr,代碼行數:24,代碼來源:BranchController.php

示例5: AddGradesAndLevels

 public static function AddGradesAndLevels($user_id, $school_year_id)
 {
     $admin = User::where('id', $user_id)->where('type', 'ecole')->first();
     if ($admin) {
         $creche = new Grade();
         $creche->name = 'Crèche';
         $creche->user_id = $user_id;
         $creche->school_year_id = $school_year_id;
         $creche->save();
         if ($creche->id) {
             $niveau = new Level();
             $niveau->niveau = 'Crèche';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $creche->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
         }
         $mater = new Grade();
         $mater->name = 'Maternelle';
         $mater->user_id = $user_id;
         $mater->school_year_id = $school_year_id;
         $mater->save();
         if ($mater) {
             $niveau = new Level();
             $niveau->niveau = 'Petite Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             $niveau = new Level();
             $niveau->niveau = 'Moyenne Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             $niveau = new Level();
             $niveau->niveau = 'Grande Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
         }
         $sc = new Grade();
         $sc->name = 'Primaire';
         $sc->user_id = $user_id;
         $sc->school_year_id = $school_year_id;
         $sc->save();
         if ($sc) {
             for ($i = 1; $i <= 6; $i++) {
                 $niveau = new Level();
                 $niveau->niveau = 'CE' . $i;
                 $niveau->user_id = $user_id;
                 $niveau->grade_id = $sc->id;
                 $niveau->school_year_id = $school_year_id;
                 $niveau->save();
             }
         }
         $col = new Grade();
         $col->name = 'Collège';
         $col->user_id = $user_id;
         $col->school_year_id = $school_year_id;
         $col->save();
         if ($col) {
             for ($i = 1; $i <= 3; $i++) {
                 if ($i == 1) {
                     $niveau = new Level();
                     $niveau->niveau = '1ère année Collège';
                     $niveau->user_id = $user_id;
                     $niveau->grade_id = $col->id;
                     $niveau->school_year_id = $school_year_id;
                     $niveau->save();
                 } elseif ($i > 1) {
                     $niveau = new Level();
                     $niveau->niveau = $i . 'ème année Collège';
                     $niveau->user_id = $user_id;
                     $niveau->grade_id = $col->id;
                     $niveau->school_year_id = $school_year_id;
                     $niveau->save();
                 }
             }
         }
         $lyc = new Grade();
         $lyc->name = 'Lycée';
         $lyc->user_id = $user_id;
         $lyc->school_year_id = $school_year_id;
         $lyc->save();
         if ($lyc) {
             $niveau = new Level();
             $niveau->niveau = 'Tronc Commun';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $lyc->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             if ($niveau->id) {
                 $l = Level::where('id', $niveau->id)->where('user_id', $user_id)->first();
                 $branchesTc = ['Tronc Commun Sciences', 'Tronc Commun Lettres et sciences humaines', 'Tronc Commun Technologique', 'Tronc Commun Enseignement Originel'];
                 foreach ($branchesTc as $br) {
                     $branche = new Branch();
                     $branche->nom_branche = $br;
                     $branche->code_branche = "";
//.........這裏部分代碼省略.........
開發者ID:khaleader,項目名稱:creche,代碼行數:101,代碼來源:Grade.php


注:本文中的app\Branch::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。