fix(smart blocks): fixing smart block model and index
This commit is contained in:
parent
9de83d062f
commit
4ce5889675
2 changed files with 20 additions and 9 deletions
|
@ -22,13 +22,17 @@ class SmartBlockController extends Controller
|
|||
* defined in app/Filters/FileFilters
|
||||
* @return string
|
||||
*/
|
||||
public function index(FileFilters $filters) {
|
||||
if (!isset($filters->per_page) || is_null($filters)) {
|
||||
$pagination = 20;
|
||||
public function index(Request $request) {
|
||||
if (!isset($request->per_page) || is_null($request)) {
|
||||
$pagination = 5;
|
||||
} else {
|
||||
$pagination = $filters->per_page;
|
||||
$pagination = $request->per_page;
|
||||
}
|
||||
return File::filter($filters)->cursorPaginate($pagination)->toJson();
|
||||
|
||||
return SmartBlock::searchFilter($request)
|
||||
->with(['creator', 'content', 'criteria'])
|
||||
->paginate($pagination)
|
||||
->toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,16 +83,16 @@ class SmartBlockController extends Controller
|
|||
$length = ($request->length_type == 'time') ? new LengthFormatter($request->length) : null;
|
||||
|
||||
$dbSmartBlock = SmartBlock::firstOrNew(['id' => $id]);
|
||||
$dbSmartBlock->fill(new Request([
|
||||
$dbSmartBlock->fill([
|
||||
'name' => $request->name,
|
||||
'creator_id' => $user->id,
|
||||
'description' => $request->description,
|
||||
'length' => $length,
|
||||
]));
|
||||
]);
|
||||
|
||||
$this->saveCriteria($dbSmartBlock, $criteria);
|
||||
|
||||
return $dbSmartBlock->with('criteria')->with('content')->get()->toJson();
|
||||
return $dbSmartBlock->with(['criteria', 'content'])->get()->toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue