1: <?php
2:
3: namespace App;
4:
5: use Illuminate\Database\Eloquent\Model;
6: use Illuminate\Support\Facades\DB;
7:
8: class Ad extends Model
9: {
10: 11: 12: 13: 14:
15: protected $table = 'ad';
16:
17:
18: 19: 20: 21: 22:
23: protected $fillable = [
24: 'link',
25: 'locations',
26: 'clicks',
27: 'banner',
28: 'central_location',
29: 'radius',
30: 'type',
31: 'title'
32: ];
33:
34: public function adLocation(){
35: return $this->hasMany('App\AdLocation');
36: }
37:
38: public function adClicks(){
39: return $this->hasMany('App\AdClick');
40: }
41: public static function uploadPicture($id, $img)
42: {
43: DB::table('ad')
44: ->where('id', $id)
45: ->update(['banner' => $img]);
46: }
47: }
48: