خرید بک لینک

Vote count: 0

Im new to Laravel and trying to get my head around basic usage.

I have the following code in my controller at the moment related to terms/taxonomy models.

$taxonomy = Taxonomy::where('slug', '=', str_slug('brand'))->first();

if ( isset($taxonomy->id) ) {

  $term = $taxonomy->term()->firstOrCreate(array('slug' => str_slug($request->name)));

  $term->name = $request->name;

  $term->save();
}

I want to make it available to other controllers and not sure of the correct place.

I thought about placing it into the Taxonomy model under a method of 'addTerm' but the Taxonomy::where() doesnt feel like its right.

What would be the correct way to do this? Should it go in the Taxonomy model or in a helper file of methods?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 1 تير 1395 ساعت: 3:53

صفحه بندی