public function run()
 {
     DB::table('libraries')->delete();
     $collection = [['fileclass_id' => 3, 'title' => 'ACH Authorization', 'filename' => 'ACH Authorization.docx', 'version' => 1, 'description' => 'none given', 'state_id' => null, 'path' => 'legal/', 'doctype_id' => 2, 'filetype_id' => 1, 'distributor_id' => null]];
     foreach ($collection as $record) {
         Library::create($record);
     }
 }
示例#2
0
 public function store(LibraryRequest $request)
 {
     $library = Library::create($request->all());
     foreach ($request->all()['categories-select'] as $key => $value) {
         $category = Category::findOrFail($value);
         $library->categories()->attach($category);
     }
     session()->flash('flash_message', 'Library "' . $library->name . '" has been created.');
     return redirect('admin/libraries');
 }
示例#3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Library::truncate();
     $dummy = Faker::create();
     $resources = Resource::all()->lists('id')->toArray();
     foreach ($resources as $resource) {
         foreach (range(5, 30) as $index) {
             Library::create(['author' => $dummy->name, 'title' => $dummy->company, 'resource_id' => $resource, 'publication' => $dummy->catchPhrase, 'quantity' => $dummy->randomDigitNotNull, 'is_active' => $dummy->boolean, 'purchased_at' => date('Y-m-d H:i:s')]);
         }
     }
 }
示例#4
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Library::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }