I have files saved in the following path: /resources/views/projects/nombreproyecto.blade.php
So, I have a form that I ask for the new name of the project and what I want to do is rename the file, for example:
I have a project called lluistestantes, because the path to the file would be the following:
/resources/views/projects/lluistestantes.blade.php
Then I fill in the form, and I put the name of lluistestdespues, the path to the file should be the following:
/resources/views/projects/lluistestdespues.blade.php
The controller that makes the function looks like this:
public function updateProject(Request $request, $id) //Actualizar la informacion de un proyecto
{
$project = Project::find($id); //Encuentro que proyecto es
$oldSlug = $project->slug; //guardo el valor ANTIGUO en la variable
$project->order = $request->input('order'); //no es importante
$project->public = $request->input('public'); //no es importante
if (strcmp($oldSlug, $request->input('slug')) !== 0) { //Si el slug cambia, entra en el IF
Storage::disk('projects')->move($project->slug, $request->input('slug')); //Se renombra la carpeta project, no darle atención a esta linea porque es independiente a la funcionalidad que busco ahora, ademas que es para archivos situados en Storage.
$project->slug = $request->input('slug'); //se pilla el valor del slug NUEVO
$project->pathheader = $request->input('slug').'/header.jpg'; //se guarda el path en la bbdd, no darle atención a esta linea porque es independiente a la funcionalidad que busco ahora.
$project->pathhome = $request->input('slug').'/home.jpg'; //se guarda el path en la bdd, no darle atención a esta linea porque es independiente a la funcionalidad que busco ahora,
File::move('/resources/views/projects/'.$oldSlug.'.blade.php','/resources/views/projects/'.$project->slug.'.blade.php'); //FUNCIÓN REALMENTE IMPORTANTE, pillo la blade antigua y la intento machacar con el nuevo valor.
}
}
The error he gives me is this:
rename(/resources/views/projects/lluistestantes.blade.php,/resources/views/projects/lluistestdespues.blade.php): No such file or directory