Running a cron job 3 times (1 pm, 2 pm and 3 pm) in Laravel
Open cronjob config with vim & add script bellow
m h dom mon dow command
- 13,14,15 * * * php /var/www/project/artisan schedule:run >> /dev/null 2>&1
v-model
on it because file inputs are readonly, so we usually add an event handler for the change
event.
type="file" @change="selectFile">
files
property that is an array of instances of the File
class. It has some metadata about the selected file and methods to read its contents. Besides that, it can be used directly as a value in a FormData
object. The FormData
class allows one to use JavaScript to build the same request that a plain HTML form would create. You can use a FormData
object as the request's body when using axios, jQuery or even plain XMLHttpRequest
objects.const data = new FormData();
data.append('photo', this.photo);
data.append('description', this.description);
data.append('productId', this.productId);
axios.post("/api/photo", data);
const data = new FormData();
data.append('photo', this.photo);
const json = JSON.stringify({
description: this.description,
productId: this.productId,
});
data.append('data', json);
axios.post("/api/photo", data);
Request
class. Uploaded files are fields like any other, presented by the framework as instances of the Illuminate\Http\UploadedFile
class. From there on you can read the file's contents or store it somewhere else.public function savePhoto(Request $request)
{
// Validate (size is in KB)
$request->validate([
'photo' => 'required|file|image|size:1024|dimensions:max_width=500,max_height=500',
]);
// Read file contents...
$contents = file_get_contents($request->photo->path());
// ...or just move it somewhere else (eg: local `storage` directory or S3)
$newPath = $request->photo->store('photos', 's3');
}
public function savePhoto(Request $request)
{
$request['data'] = json_decode($request['data']);
// Validate
$request->validate([
'data.description' => 'required|filled|size:100',
'data.productId' => 'required|int|exists:App\Product,id'
]);
// ...the rest is the same...
}