<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Ad; use Illuminate\Http\Request; class AdsController extends Controller {public function index(){return view('admin.ads',['items'=>Ad::latest()->get()]);} public function store(Request $r){$d=$r->validate(['name'=>'required','slot'=>'required','type'=>'required','content'=>'nullable','target_url'=>'nullable|url','is_active'=>'nullable']);$d['is_active']=$r->boolean('is_active');Ad::create($d);return back()->with('ok','Ad saved.');} public function destroy(Ad $ad){$ad->delete();return back();} public function toggle(Ad $ad){$ad->update(['is_active'=>!$ad->is_active]);return back();}}