Clean models relations and comply with phpcs

This commit is contained in:
Jérémy Munsch 2021-02-04 19:06:12 +01:00
parent f38e95bce8
commit 1393a891aa
24 changed files with 110 additions and 71 deletions

View file

@ -8,19 +8,26 @@ class Articles extends Model
{
public function category()
{
return $this->belongsTo('App\Models\ArticlesCategories');
return $this->belongsTo(ArticlesCategories::class);
}
public function recipes() {
return $this->belongsToMany('App\Models\Recipes', 'recipes_articles', 'article_id', 'recipe_id');
public function recipes()
{
return $this->belongsToMany(Recipes::class);
}
public function answers()
{
return $this->hasMany('App\Models\SurveysAnswers', 'article_id');
return $this->hasMany(SurveysAnswers::class);
}
public function surveys_answers_users() {
return $this->hasManyThrough('App\Models\SurveysAnswers', 'App\Models\SurveysAnswersUsers', 'survey_answer_id', 'article_id');
public function surveysAnswersUsers()
{
return $this->hasManyThrough(
SurveysAnswers::class,
SurveysAnswersUsers::class,
'survey_answer_id',
'article_id'
);
}
}

View file

@ -8,6 +8,6 @@ class ArticlesCategories extends Model
{
public function articles()
{
return $this->hasMany('App\Models\Articles');
return $this->hasMany(Articles::class);
}
}

View file

@ -16,7 +16,8 @@ class BalancedMenus extends Model
protected $table = 'balanced_menus';
public function product() {
return $this->belongsTo('App\Models\Products', 'product_id');
public function product()
{
return $this->belongsTo(Products::class);
}
}

View file

@ -12,11 +12,11 @@ class Breeders extends Model
public function site()
{
return $this->hasOne('App\Models\BreedersSites', 'breeder_id');
return $this->hasOne(BreedersSites::class);
}
public function inuavs()
{
return $this->hasMany('App\Models\BreedersInuav', 'breeder_id');
return $this->hasMany(BreedersInuav::class);
}
}

View file

@ -11,6 +11,6 @@ class BreedersInuav extends Model
public function breeder()
{
return $this->belongsTo('App\Models\Breeders', 'breeder_id');
return $this->belongsTo(Breeders::class);
}
}

View file

@ -16,6 +16,6 @@ class BreedersSites extends Model
public function breeder()
{
return $this->belongsTo('App\Models\Breeders', 'breeder_id');
return $this->belongsTo(Breeders::class);
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class ConsumptionTimes extends Model
{
public function products() {
return $this->hasMany('App\Models\Products', 'consumption_times_id');
public function products()
{
return $this->hasMany(Products::class, 'consumption_times_id');
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class Countries extends Model
{
public function products() {
return $this->hasMany('App\Models\Products', 'country_id');
public function products()
{
return $this->hasMany(Products::class, 'country_id');
}
}

View file

@ -11,19 +11,23 @@ class Customers extends Authenticatable
protected $guard = 'customer';
public function recipes() {
return $this->belongsToMany('App\Models\Recipes', 'customer_recipe', 'customer_id', 'recipe_id');
public function recipes()
{
return $this->belongsToMany(Recipes::class);
}
public function products() {
return $this->belongsToMany('App\Models\Products', 'cart', 'customer_id', 'product_id');
public function products()
{
return $this->belongsToMany(Products::class, 'cart');
}
public function forums() {
return $this->hasMany('App\Models\Forum', 'customer_id');
public function forums()
{
return $this->hasMany(Forum::class);
}
public function answers() {
return $this->hasMany('App\Models\ForumAnswers', 'customer_id');
public function answers()
{
return $this->hasMany(ForumAnswers::class);
}
}

View file

@ -8,7 +8,7 @@ class FaqQuestions extends Model
{
public function theme()
{
return $this->belongsTo('App\Models\FaqThemes');
return $this->belongsTo(FaqThemes::class);
}
public function getUtilityAttribute() {

View file

@ -8,6 +8,6 @@ class FaqThemes extends Model
{
public function questions()
{
return $this->hasMany('App\Models\FaqQuestions');
return $this->hasMany(FaqQuestions::class);
}
}

View file

@ -6,15 +6,18 @@ use Illuminate\Database\Eloquent\Model;
class Forum extends Model
{
public function theme() {
return $this->belongsTo('App\Models\ForumThemes', 'theme_id');
public function theme()
{
return $this->belongsTo(ForumThemes::class, 'theme_id');
}
public function customer() {
return $this->belongsTo('App\Models\Customers', 'customer_id');
public function customer()
{
return $this->belongsTo(Customers::class, 'customer_id');
}
public function answers() {
return $this->hasMany('App\Models\ForumAnswers', 'forum_id');
public function answers()
{
return $this->hasMany(ForumAnswers::class, 'forum_id');
}
}

View file

@ -6,11 +6,13 @@ use Illuminate\Database\Eloquent\Model;
class ForumAnswers extends Model
{
public function forum() {
return $this->belongsTo('App\Models\Forum', 'forum_id');
public function forum()
{
return $this->belongsTo(Forum::class);
}
public function customer() {
return $this->belongsTo('App\Models\Customers', 'customer_id');
public function customer()
{
return $this->belongsTo(Customers::class);
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class ForumThemes extends Model
{
public function forums() {
return $this->hasMany('App\Models\Forum', 'theme_id');
public function forums()
{
return $this->hasMany(Forum::class, 'theme_id');
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class MeatTypes extends Model
{
public function products() {
return $this->hasMany('App\Models\Products', 'meat_type_id');
public function products()
{
return $this->hasMany(Products::class, 'meat_type_id');
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class Moments extends Model
{
public function strates() {
return $this->hasMany('App\Models\MomentStrates', 'moment_id');
public function strates()
{
return $this->hasMany(MomentStrates::class);
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class ProductPictograms extends Model
{
public function products() {
return $this->belongsToMany('App\Models\Products', "products_pictograms", "id_pictogram", "id_product");
public function products()
{
return $this->belongsToMany(Products::class, "products_pictograms", "id_pictogram", "id_product");
}
}

View file

@ -25,63 +25,75 @@ class Products extends Model
return $this->belongsTo(Ranges::class);
}
//TODO: PSR1 is not in camel caps format
public function meat_type()
{
return $this->belongsTo('App\Models\MeatTypes', 'meat_type_id');
return $this->belongsTo(MeatTypes::class, 'meat_type_id');
}
//TODO: PSR1 is not in camel caps format
public function consumption_times()
{
return $this->belongsTo('App\Models\ConsumptionTimes', 'consumption_times_id');
return $this->belongsTo(ConsumptionTimes::class, 'consumption_times_id');
}
public function recipe()
{
return $this->belongsTo('App\Models\Recipes', 'recipe_id');
return $this->belongsTo(Recipes::class);
}
public function country()
{
return $this->belongsTo('App\Models\Countries', 'country_id');
return $this->belongsTo(Countries::class, 'country_id ');
}
public function society()
{
return $this->belongsTo('App\Models\Societies', 'society_id');
return $this->belongsTo(Societies::class, 'society_id ');
}
//TODO: PSR1 is not in camel caps format
public function sale_family()
{
return $this->belongsTo('App\Models\SalesFamilies', 'sale_family_id');
return $this->belongsTo(SalesFamilies::class, 'sale_family_id ');
}
//TODO: PSR1 is not in camel caps format
public function inco_nutritional_values()
{
return $this->hasOne('App\Models\INCONutritionalValues', 'product_id');
return $this->hasOne(INCONutritionalValues::class);
}
//TODO: PSR1 is not in camel caps format
public function balanced_menu()
{
return $this->hasOne('App\Models\BalancedMenus', 'product_id');
return $this->hasOne(BalancedMenus::class);
}
public function recipes()
{
return $this->belongsToMany(Recipes::class);
}
//TODO: PSR1 is not in camel caps format
public function recipes_associated_1()
{
return $this->hasMany('App\Models\Recipes', 'associated_product1');
return $this->hasMany(Recipes::class, 'associated_product1 ');
}
//TODO: PSR1 is not in camel caps format
public function recipes_associated_2()
{
return $this->hasMany('App\Models\Recipes', 'associated_product2');
return $this->hasMany(Recipes::class, 'associated_product2 ');
}
public function customers()
{
return $this->belongsToMany('App\Models\Customers', 'cart', 'product_id', 'customer_id');
return $this->belongsToMany(Customers::class, 'cart');
}
public function reductions()
{
return $this->belongsToMany('App\Models\Reductions', 'reduction_config', 'product_id', 'reduction_id');
return $this->belongsToMany(Reductions::class, 'reduction_config');
}
}

View file

@ -22,6 +22,6 @@ class Ranges extends Model
public function reductions()
{
return $this->belongsToMany('App\Models\Reductions', 'reduction_config', 'range_id', 'reduction_id');
return $this->belongsToMany(Reductions::class, 'reduction_config');
}
}

View file

@ -27,21 +27,21 @@ class Recipes extends Model
public function products()
{
return $this->hasMany('App\Models\Products', 'recipe_id');
return $this->hasMany(Products::class);
}
public function product1()
{
return $this->belongsTo('App\Models\Products', 'associated_product1');
return $this->belongsTo(Products::class, 'associated_product1');
}
public function product2()
{
return $this->belongsTo('App\Models\Products', 'associated_product2');
return $this->belongsTo(Products::class, 'associated_product2');
}
public function customers()
{
return $this->belongsToMany('App\Models\Customers', 'customer_recipe', 'recipe_id', 'customer_id');
return $this->belongsToMany(Customers::class);
}
}

View file

@ -6,11 +6,13 @@ use Illuminate\Database\Eloquent\Model;
class Reductions extends Model
{
public function products() {
return $this->belongsToMany('App\Models\Products', 'reduction_config', 'reduction_id', 'product_id');
public function products()
{
return $this->belongsToMany(Products::class, 'reduction_config');
}
public function ranges() {
return $this->belongsToMany('App\Models\Ranges', 'reduction_config', 'reduction_id', 'range_id');
public function ranges()
{
return $this->belongsToMany(Ranges::class, 'reduction_config', 'reduction_id', 'range_id');
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class SalesFamilies extends Model
{
public function products() {
return $this->hasMany('App\Models\Products', 'sale_family_id');
public function products()
{
return $this->hasMany(Products::class, 'sale_family_id');
}
}

View file

@ -6,7 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class Societies extends Model
{
public function products() {
return $this->hasMany('App\Models\Products', 'society_id');
public function products()
{
return $this->hasMany(Products::class, 'society_id');
}
}

View file

@ -11,6 +11,6 @@ class SurveysAnswers extends Model
public function article()
{
return $this->belongsTo('App\Models\Articles', 'article_id');
return $this->belongsTo(Articles::class);
}
}