api code global jain
This commit is contained in:
62
app/Models/Traits/Jati/Attributes/JatiAttributes.php
Normal file
62
app/Models/Traits/Jati/Attributes/JatiAttributes.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\Jati\Attributes;
|
||||
|
||||
use App\Constant\Constant;
|
||||
use App\Traits\ActionButtons;
|
||||
|
||||
trait JatiAttributes
|
||||
{
|
||||
use ActionButtons;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJatiStatusActionAttribute(): string
|
||||
{
|
||||
return $this->statusLabel($this->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJatiEditActionAttribute(): string
|
||||
{
|
||||
return $this->editButton(route('admin.jati.edit', $this->id), 'Edit Jati');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJatiDeleteActionAttribute(): string
|
||||
{
|
||||
// if (loggedInUser()->id != $this->id) {
|
||||
return $this->deleteButton($this->id, 'Delete Jati');
|
||||
// }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJatiCheckboxActionAttribute(): string
|
||||
{
|
||||
return $this->checkboxAction($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJatiActionButtonsAttribute(): string
|
||||
{
|
||||
$action = $this->jati_edit_action;
|
||||
$action =$action.$this->jati_view_action;
|
||||
if (loggedInUser()->isSuperAdmin() || loggedInUser()->isAdmin()) {
|
||||
if (!$this->userDetails()->exists()) {
|
||||
$action =$action.$this->jati_delete_action;
|
||||
}
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
39
app/Models/Traits/Jati/Relationships/JatiRelationships.php
Normal file
39
app/Models/Traits/Jati/Relationships/JatiRelationships.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\Jati\Relationships;
|
||||
|
||||
use App\Constant\Constant;
|
||||
use App\Models\Dharma;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
|
||||
/**
|
||||
* Trait UserRelationships
|
||||
* @package Domains\User\Models\Traits\Relationships
|
||||
*/
|
||||
trait JatiRelationships
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function dharma()
|
||||
{
|
||||
return $this->belongsTo(Dharma::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function userDetails()
|
||||
{
|
||||
return $this->hasMany(UserDetail::class, 'jati_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user