api code global jain
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\ChaturmasDate\Attributes;
|
||||
|
||||
use App\Traits\ActionButtons;
|
||||
|
||||
trait ChaturmasDateAttributes
|
||||
{
|
||||
use ActionButtons;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChaturmasDateStatusActionAttribute(): string
|
||||
{
|
||||
return $this->statusLabel($this->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChaturmasDateEditActionAttribute(): string
|
||||
{
|
||||
return $this->editButton(route('admin.chaturmas-date.edit', $this->id), 'Edit Chaturmas Date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChaturmasDateDeleteActionAttribute(): string
|
||||
{
|
||||
// if (loggedInUser()->id != $this->id) {
|
||||
return $this->deleteButton($this->id, 'Delete Chaturmas Date');
|
||||
// }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChaturmasDateCheckboxActionAttribute(): string
|
||||
{
|
||||
return $this->checkboxAction($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChaturmasDateActionButtonsAttribute(): string
|
||||
{
|
||||
$action = $this->chaturmas_date_edit_action;
|
||||
$action =$action.$this->chaturmas_date_view_action;
|
||||
if (loggedInUser()->isSuperAdmin() || loggedInUser()->isAdmin()) {
|
||||
// if (!$this->chaturmas()->exists()) {
|
||||
$action =$action.$this->chaturmas_date_delete_action;
|
||||
// }
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns model in days since created_at.
|
||||
*/
|
||||
public function getCreatedAgoAttribute() {
|
||||
return $this->created_at->diffForHumans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns model in days since updated_at.
|
||||
*/
|
||||
public function getUpdatedAgoAttribute() {
|
||||
return $this->updated_at->diffForHumans();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\ChaturmasDate\Methods;
|
||||
|
||||
trait ChaturmasDateMethods
|
||||
{
|
||||
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\ChaturmasDate\Relationships;
|
||||
|
||||
use App\Models\Chaturmas;
|
||||
use App\Models\ChaturmasReview;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Trait ChaturmasRelationships
|
||||
* @package Domains\Chaturmas\Models\Traits\Relationships
|
||||
*/
|
||||
trait ChaturmasDateRelationships
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function updatedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'updated_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function chaturmas()
|
||||
{
|
||||
return $this->hasMany(Chaturmas::class, 'chaturmas_date_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function reviews()
|
||||
{
|
||||
return $this->belongsTo(ChaturmasReview::class, 'chaturmas_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits\ChaturmasDate\Scopes;
|
||||
|
||||
trait ChaturmasDateScope
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user