Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Channel $channel)
 {
     $channel->update($request->except('file'));
     if ($request->hasFile('file')) {
         $file = $request->file('file');
         $dir = 'img/icons';
         $name = $channel->id() . '.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         $channel->file = $dir . '/' . $name;
         $channel->save();
         $file->move($dir, $name);
     }
     return redirect()->route('admin.channel.show', $channel);
 }
Ejemplo n.º 2
0
 public function scopeGeneral($query, \Model\Channel\ModelName $channel = null)
 {
     return $query->where('general', '=', true)->orWhere('channel_id', '=', $channel->id());
 }