public function add() { $file = Request::file('file'); if (Request::hasFile('file')) { $extension = $file->getClientOriginalExtension(); Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file)); $entry = new \App\File(); $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $file->getFilename() . '.' . $extension; $entry->save(); $part = new Part(); $part->file_id = $entry->id; $part->name = Request::input('name'); $part->sku = Request::input('sku'); $part->make = Request::input('make'); $part->year = Request::input('year'); $part->condition = Request::input('condition'); $part->description = Request::input('description'); $part->price = Request::input('price'); $part->imageurl = Request::input('imageurl'); if (Request::has('price')) { $part->save(); } } return redirect('/admin/part'); }
public function add() { $file = Request::file('file'); $entry = new \App\File(); $entry->save(); $product = new Product(); $product->file_id = $entry->id; $product->name = Request::input('name'); $product->description = Request::input('description'); $product->price = Request::input('price'); $product->imageurl = Request::input('imageurl'); $product->save(); return redirect('/admin/products'); }
/** * Basically a create. * * @return \Illuminate\Http\Response */ public function add() { $file = Request::file('file'); $extension = $file->getClientOriginalExtension(); Storage::disk('local')->put($file->getFileName() . '.' . $extension, File::get($file)); $entry = new \App\File(); $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $file->getFileName() . '.' . $extension; $entry->save(); $product = new Product(); $product->file_id = $entry->id; $product->name = Request::input('name'); $product->description = Request::input('description'); $product->price = Request::input('price'); $product->imageurl = Request::input('imageurl'); $product->save(); return redirect('/admin/products'); }
return ['code' => strtoupper($faker->bothify('??##??#?')), 'style' => rand(0, 4) ? ucwords(join(' ', $faker->words(rand(1, 4)))) : '', 'description' => $faker->paragraph, 'specs' => collect($specs)]; }); $factory->define(App\File::class, function (Faker\Generator $faker) { $generated = $faker->file('/tmp', storage_path()); $filename = \File::name($generated) . '.pdf'; $filepath = public_path() . '/files/' . $filename; $saved = \File::move($generated, $filepath); return ['path' => 'files/' . $filename, 'mime' => \File::mimeType($filepath), 'extension' => \File::extension($filepath), 'size' => \File::size($filepath)]; }); $factory->define(App\SafetyDataSheet::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\DataSheet::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\Brochure::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\Image::class, function (Faker\Generator $faker) { $file = new App\File(); $generated = $faker->image('/tmp', 1024, 768); $filename = \File::name($generated) . '.' . \File::extension($generated); $filepath = public_path() . '/files/' . $filename; $saved = \File::move($generated, $filepath); $fileEntity = App\File::create(['path' => 'files/' . $filename, 'mime' => \File::mimeType($filepath), 'extension' => \File::extension($filepath), 'size' => \File::size($filepath)]); return ['title' => ucwords(join(' ', $faker->words(rand(1, 4)))), 'file_id' => $fileEntity->id]; }); $factory->define(App\Industry::class, function (Faker\Generator $faker) { $name = ucwords(join(' ', $faker->words(rand(1, 4)))); return ['name' => $name, 'slug' => str_slug($name)]; });
}); Route::bind('notice', function ($id) { /** @var int $id */ return App\Notice::where('id', $id)->first(); }); Route::bind('group', function ($username) { /** @var int $id */ return App\Group::where('username', $username)->first(); }); Route::bind('folder', function ($id) { /** @var int $id */ return App\Folder::find($id); }); Route::bind('file', function ($id) { /** @var int $id */ return App\File::find($id); }); Route::bind('code', function ($code) { /** @var int $code */ return App\User::where('code', $code)->first(); }); /**Route::bind('school' , function($school) { @var TYPE_NAME $id return App\User::where('username', '==' ,$school); });*/ /* The testing route */ Route::get('/test/mail', function () { return view('inspina.email.confirm'); }); /* Testing Route Ends */