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


PHP Book::fill方法代碼示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(BookRequest $request)
 {
     if (Input::file('cover')->isValid()) {
         $file = Input::file('cover');
         $destinationPath = 'images/cover';
         $fileName = rand(11111, 99999) . '_' . $file->getClientOriginalName();
         Input::file('cover')->move($destinationPath, $fileName);
         $data = new Book();
         $data->fill($request->all());
         $data->cover = $fileName;
         $data->save();
         return Redirect('admin/books')->with('successMessage', 'Berhasil menambah buku.');
     } else {
         return Redirect()->back();
     }
 }
開發者ID:satriowisnugroho,項目名稱:LIST,代碼行數:21,代碼來源:BookController.php

示例2: importBooks

 public function importBooks()
 {
     $rules = array('csvfile' => 'required|mimes:csv,txt');
     try {
         $file = Input::file('csvfile');
         if (is_null($file)) {
             throw new Exception("File upload required");
         }
         Excel::load($file, function ($reader) {
             $results = $reader->all();
             foreach ($results as $row) {
                 $book = new Book();
                 # First row should be like "Title, Author"
                 $data = array('title' => $row->title, 'author' => $row->author);
                 $book->fill($data);
                 $book->save();
             }
         });
     } catch (Exception $e) {
         return Redirect::to('/')->with(['books' => Book::all(), 'errors' => $e->getMessage()]);
     }
     return Redirect::to('/')->with(['books' => Book::all()]);
     //return Redirect::to('/')->with('csvdata', $results);
 }
開發者ID:vertexclique,項目名稱:bstore,代碼行數:24,代碼來源:BookController.php

示例3: generate

 public function generate($vendor_slug, $tour_slug, $schedule_id)
 {
     // -------------------------------------------------
     // check vendor
     // -------------------------------------------------
     $vendor = Vendor::SlugIs($vendor_slug)->first();
     if (!$vendor) {
         App::abort(404);
     }
     // -------------------------------------------------
     // check tour
     // -------------------------------------------------
     $tour = $vendor->tours()->slugIs($tour_slug)->first();
     if (!$tour) {
         App::abort(404);
     }
     // -------------------------------------------------
     // schedule
     // -------------------------------------------------
     $schedule = $tour->schedules()->find($schedule_id);
     if (!$schedule) {
         App::abort(404);
     }
     // -------------------------------------------------
     // generate voucher
     // -------------------------------------------------
     $book = Book::where('user_id', '=', Auth::id())->ofSchedule($schedule->id)->first();
     if (!$book) {
         $book = new Book();
         $book->fill(['discount_currency' => $schedule->currency, 'discount' => $schedule->discount, 'discount_code' => str_random(6), 'user_id' => Auth::id(), 'schedule_id' => $schedule->id]);
         if (!$book->save()) {
             return redirect()->back()->withErrors($book->getErrors);
         }
     }
     return redirect()->route('web.me.index');
 }
開發者ID:ThunderID,項目名稱:capcus.v2,代碼行數:36,代碼來源:VoucherController.php


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