This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* very wip * wip * wip * wip * wip * wip * wip * wip * Applied fixes from StyleCI * wip * wip * wip * Wip * Wip * Wip * Wip * Apply fixes from StyleCI * Fixes * wip * Apply fixes from StyleCI * Updated deps * wip * wip * wip * Fixes * Layout wip * Module active editor row * redactor toolbar * Drag color * user-select on modules * sticky redactor * sticky redactor * Updated deps * Alternative styles for modules * Alternative styles for modules * Select2 * Alternative styles for modules * Alternative styles for modules * Remove console log * Alternative styles for modules * Alternative styles for modules * Redactor select in module row * Wip * Order column * Remove blender-css * Removed yarn-error.log * Updated gitignore * Dead code * Dead code * Cleanup & fixes * Content blocks * Use external lib * Apply fixes from StyleCI * Article * Media * Finalize
- Loading branch information
1 parent
d583090
commit 398f960
Showing
28 changed files
with
1,236 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
"transform-object-rest-spread" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "spatie", | ||
"extends": "spatie/vue", | ||
"globals": { | ||
"$": true, | ||
"jQuery": true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Back\Api; | ||
|
||
use App\Models\ContentBlock; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Database\Eloquent\Model; | ||
use App\Http\Requests\Back\ContentBlockRequest; | ||
use App\Models\Transformers\ContentBlockTransformer; | ||
|
||
class ContentBlockController extends Controller | ||
{ | ||
public function add(ContentBlockRequest $request) | ||
{ | ||
$model = $this->getModelFromRequest($request); | ||
|
||
$contentBlock = new ContentBlock(['collection_name' => $request->collection_name]); | ||
|
||
$model->contentBlocks()->save($contentBlock); | ||
|
||
return fractal($contentBlock, new ContentBlockTransformer()); | ||
} | ||
|
||
protected function getModelFromRequest(ContentBlockRequest $request): Model | ||
{ | ||
return call_user_func($request['model_name'].'::findOrFail', $request['model_id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Back; | ||
|
||
use App\Http\Requests\Request; | ||
use Illuminate\Contracts\Validation\Validator; | ||
|
||
class ContentBlockRequest extends Request | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'model_name' => 'required', | ||
'model_id' => 'required', | ||
'collection_name' => 'required', | ||
]; | ||
|
||
return $rules; | ||
} | ||
|
||
protected function failedValidation(Validator $validator) | ||
{ | ||
return response()->json($validator->messages(), 400); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Support\Arr; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Spatie\Translatable\HasTranslations; | ||
use Spatie\Blender\Model\Traits\HasMedia; | ||
use Spatie\Blender\Model\Traits\Draftable; | ||
use Spatie\EloquentSortable\SortableTrait; | ||
use Illuminate\Database\Eloquent\Relations\MorphTo; | ||
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions; | ||
|
||
class ContentBlock extends Model implements HasMediaConversions | ||
{ | ||
use Draftable, SortableTrait, HasTranslations, HasMedia; | ||
|
||
public $translatable = ['name', 'text']; | ||
protected $guarded = []; | ||
|
||
public function subject(): MorphTo | ||
{ | ||
return $this->morphTo('model'); | ||
} | ||
|
||
public function registerMediaConversions() | ||
{ | ||
$this->addMediaConversion('admin') | ||
->setWidth(368) | ||
->setHeight(232) | ||
->nonQueued(); | ||
|
||
$this->addMediaConversion('thumb') | ||
->setWidth(368) | ||
->setHeight(232); | ||
|
||
$this->addMediaConversion('detail') | ||
->setWidth(740); | ||
} | ||
|
||
public function mediaLibraryCollections(): array | ||
{ | ||
return $this->subject->getContentBlockMediaLibraryCollections(); | ||
} | ||
|
||
public function mediaLibraryCollectionType(string $name): string | ||
{ | ||
return $this->subject->getContentBlockMediaLibraryCollections()[$name]; | ||
} | ||
|
||
public function updateWithAttributes(array $values) | ||
{ | ||
$this->draft = false; | ||
$this->type = $values['type']; | ||
|
||
foreach ($this->translatable as $attribute) { | ||
$this->setTranslations($attribute, $values[$attribute] ?? []); | ||
} | ||
|
||
foreach ($this->mediaLibraryCollections() as $collection) { | ||
if (! isset($values[$collection])) { | ||
continue; | ||
} | ||
|
||
$media = array_filter($values[$collection], function ($media) { | ||
return ($media['markedForRemoval'] ?? false) !== true; | ||
}); | ||
|
||
$updatedMedia = $this->updateMedia($media, $collection); | ||
|
||
$this->media() | ||
->whereCollectionName($collection) | ||
->whereNotIn('id', Arr::pluck($updatedMedia, 'id')) | ||
->delete(); | ||
} | ||
|
||
$this->save(); | ||
|
||
return $this; | ||
} | ||
|
||
public function setOrder(int $i) | ||
{ | ||
$this->order_column = $i; | ||
|
||
$this->save(); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.