Skip to content

Commit

Permalink
WIP API models need to implement TwillModelContract
Browse files Browse the repository at this point in the history
There is still a failing test
  • Loading branch information
zachgarwood committed Nov 22, 2024
1 parent 1382838 commit f8e87d0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
32 changes: 31 additions & 1 deletion app/Libraries/Api/Models/BaseApiModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace App\Libraries\Api\Models;

use A17\Twill\Models\Behaviors\HasPresenter;
use A17\Twill\Models\Contracts\TwillModelContract;
use App\Libraries\Api\Models\ApiCollection as BaseCollection;
use App\Libraries\Api\Models\Behaviors\HasApiCalls;
use App\Libraries\Api\Models\Behaviors\HasAugmentedModel;
Expand All @@ -18,12 +19,13 @@
use Illuminate\Contracts\Routing\UrlRoutable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use JsonSerializable;

abstract class BaseApiModel implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, UrlRoutable
abstract class BaseApiModel implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, TwillModelContract, UrlRoutable
{
use HasApiCalls;
use HasAugmentedModel;
Expand Down Expand Up @@ -1089,6 +1091,34 @@ public function getKeyName()
return $this->primaryKey;
}

/**
* TODO: Implement TwillModelContract
*/
public function scopePublished(Builder $query): Builder
{
return $query;
}

public function scopeAccessible(Builder $query): Builder
{
return $query;
}

public function scopeOnlyTrashed(Builder $query): Builder
{
return $query;
}

public function scopeDraft(Builder $query): Builder
{
return $query;
}

public function getTranslatedAttributes(): array
{
return array();
}

/**
* Determine if an attribute exists on the model.
*
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Api/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Libraries\Api\Models\BaseApiModel;
use App\Libraries\Api\Builders\ApiModelBuilderSearch;
use App\Libraries\Search\Filters\Departments as DepartmentFilter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use App\Helpers\DateHelpers;
Expand Down Expand Up @@ -864,7 +865,7 @@ public function scopePublic($query)
return $query->rawSearch($params);
}

public function scopePublished($query)
public function scopePublished(Builder $query): Builder
{
$params = [
'bool' => [
Expand Down

0 comments on commit f8e87d0

Please sign in to comment.