Skip to main content

aschmelyun/laravel-job-board

174 stars
1 code files
View aschmelyun/laravel-job-board on GitHub

app/Http/Controllers/ListingController.php

Open in GitHub
use App\Models\Tag;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
 
class ListingController extends Controller
{
//
public function store(Request $request)
{
//
foreach(explode(',', $request->tags) as $requestTag) {
$tag = Tag::firstOrCreate([
'slug' => Str::slug(trim($requestTag))
], [
'name' => ucwords(trim($requestTag))
]);
 
$tag->listings()->attach($listing->id);
}
//
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.