-
app/Models/Listing.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Listing extends Model { public function clicks() { return $this->hasMany(Click::class); } // }
-
app/Http/Controllers/ListingController.php
Open in GitHubuse App\Models\Listing; use Illuminate\Http\Request; class ListingController extends Controller { // public function apply(Listing $listing, Request $request) { $listing->clicks() ->create([ 'user_agent' => $request->userAgent(), 'ip' => $request->ip() ]); return redirect()->to($listing->apply_link); } // }