Reputation: 83
I'm a newbie in Laravel framework.
Here is my purpose:-
I stored a report file in HTML format inside view folder because I need to restrict access to this view. Currently, I route and send a parameter of a blade file parsing to my controller.
My controller delete function as follows:-
public function centos7_delete($id)
{
//
$user = Auth::user();
if($user){
\File::Delete('/resources/views/report/centos7/'. $id);
echo '/resources/views/report/centos7/'. $id;
return view('centos7dir');
} else {
return redirect('/permission_denied');
}
}
An example filename which is routed and parsed to Controller.
result_target2.blade.php
I'm not sure, how many ways to do it on the Laravel framework? Please help me suggest or provide some guidelines.
Thank you.
Upvotes: 1
Views: 889
Reputation: 3284
Okay i did it like this,
use Illuminate\Support\Facades\File;
Route::get('/test',function(){
//dd(base_path('resources/views/test.blade.php'));
$isDelted = File::delete(base_path('resources/views/test.blade.php'));
dd($isDelted); // returns true if deleted if not false
})->name('test');
One more thing i would like to add , make sure to give permission to read and write to folder.
I hope this helps.
Upvotes: 1