Posts

Showing posts with the label laravel-5

store foreign key as zero instead of it's value

store foreign key as zero instead of it's value I have a table that all the values are foreign keys ,when I store these values it save it as zero not the value that I chose , public function create() { $type=type::query()->pluck('type'); $color=color::query()->pluck('colore'); $region=region::query()->pluck('country'); $size=size::query()->pluck('size'); $brand=brand::query()->pluck('company'); //$price=new_product::query()->pluck('price'); return view('sale',compact('type','color','region','size','brand')); } public function store(Request $request) { new_product::create($request->all()); return redirect()->route('sale.index'); } the model: class new_product extends Model { protected $table = 'enter_new_product'; protected $fillable = ['type_id', 'color_id', 'region_id', 'size_...

Laravel, trying to use helper to display PDF

Laravel, trying to use helper to display PDF I'm trying to display a PDF file I have in my storagereports folder inline in the browser. My file is: storagereportsReal_Estate_Test.pdf storagereportsReal_Estate_Test.pdf I have a helper file: appHelpershelpers.php appHelpershelpers.php I call the PDF from my blade with: {{viewReport($filepath, $ext, $filename)}} {{viewReport($filepath, $ext, $filename)}} where $filepath = storage_path().'reports'; $ext = "pdf"; $filename = "Real_Estate_Test"; In my helper file I have: <?php use Response; if (! function_exists('viewReport')) { function viewReport($filepath, $ext, $filename) { $filename.".".$ext, , 'inline'); $headers = [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; ' . $filepath."\".$filename.".".$ext, ]; return Response::make(File::get($file...