-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Scope Folder to selected users & return folders/media to API …
- Loading branch information
Showing
27 changed files
with
680 additions
and
212 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
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
39 changes: 39 additions & 0 deletions
39
database/migrations/2024_10_03_171809_create_folder_has_models_table.php
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,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('folder_has_models', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
//Morph | ||
$table->string('model_type'); | ||
$table->unsignedBigInteger('model_id'); | ||
|
||
//Folder | ||
$table->foreignId('folder_id')->constrained('folders')->onDelete('cascade'); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('media_has_models'); | ||
} | ||
}; |
38 changes: 38 additions & 0 deletions
38
database/migrations/2024_10_03_171810_update_folders_table.php
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,38 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('folders', function (Blueprint $table) { | ||
$table->boolean('is_public')->default(true)->nullable(); | ||
$table->boolean('has_user_access')->default(false)->nullable(); | ||
$table->unsignedBigInteger('user_id')->nullable(); | ||
$table->string('user_type')->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('folders', function (Blueprint $table) { | ||
$table->dropColumn('is_public'); | ||
$table->dropColumn('has_user_access'); | ||
$table->dropColumn('user_id'); | ||
$table->dropColumn('user_type'); | ||
}); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
Route::middleware(config('filament-media-manager.api.middlewares'))->prefix(config('filament-media-manager.api.prefix'))->name('media-manager.')->group(function (){ | ||
Route::get('/folders', [\TomatoPHP\FilamentMediaManager\Http\Controllers\FolderController::class, 'index'])->name('folders.index'); | ||
Route::get('/folders/{id}', [\TomatoPHP\FilamentMediaManager\Http\Controllers\FolderController::class, 'show'])->name('folders.show'); | ||
}); |
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
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,36 @@ | ||
<?php | ||
|
||
namespace TomatoPHP\FilamentMediaManager\Http\Controllers; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Spatie\MediaLibrary\MediaCollections\Models\Media; | ||
use TomatoPHP\FilamentMediaManager\Http\Resources\FolderResource; | ||
use TomatoPHP\FilamentMediaManager\Http\Resources\FoldersResource; | ||
use TomatoPHP\FilamentMediaManager\Http\Resources\MediaResource; | ||
use TomatoPHP\FilamentMediaManager\Models\Folder; | ||
|
||
class FolderController extends Controller | ||
{ | ||
public function index(Request $request) | ||
{ | ||
$folders = config('filament-media-manager.model.folder')::query(); | ||
|
||
if ($request->has('search')) { | ||
$folders->where('name', 'like', '%'.$request->search.'%'); | ||
} | ||
|
||
return response()->json([ | ||
'data' => config('filament-media-manager.api.resources.folders')::collection($folders->paginate(10)) | ||
], 200); | ||
} | ||
|
||
public function show(int $id) | ||
{ | ||
$folder = Folder::query()->findOrFail($id); | ||
|
||
return response()->json([ | ||
'data' => config('filament-media-manager.api.resources.folder')::make($folder) | ||
], 200); | ||
} | ||
} |
Empty file.
Empty file.
Oops, something went wrong.