Class 'Pbmedia\LaravelFFMpeg\FFMpegServiceProvider' not found - laravel-5

'providers' => [
...
Pbmedia\LaravelFFMpeg\FFMpegServiceProvider::class,
...
];
'aliases' => [
...
'FFMpeg' => Pbmedia\LaravelFFMpeg\FFMpegFacade::class
...
];
Publish the config file using the artisan CLI tool:
php artisan vendor:publish --provider="Pbmedia\LaravelFFMpeg\FFMpegServiceProvider"
$artist = $req->input('artist_id');
$audition = $req->input('audition_id');
$id=Crypt::encrypt($audition);
$vid1 = $req->file("video");
$file = "vid1".time().'.'.$vid1->getClientOriginalExtension();
$file1 = FFMPEG\FFMpeg::open($file);
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($file);
$video
->filters()
->resize(new FFMpeg\Coordinate\Dimension(320, 240))
->synchronize();
$vid1->move(public_path('/auditions'),$video);

Related

updated image stores in database but not folder in laravel

problem is that company_photo stores in database but not store in company_photos folder, please tell me where i going wrong..
public function update(Request $request, Company $company,CompanyOtherInfo $CompanyOtherInfo )
{
//dd($company);
//dd(request()->all());
if($request->hasFile('company_photo')){
$files=public_path().'/company_photos/'.$req->input('company_photo1');
File::delete($files);
//dd($files);
$file = $req->file('company_photo');
$destinationPath = public_path().'/company_photos/';
$filename = $file->getClientOriginalName();
$file->move($destinationPath, $filename);
// echo $filename;
}
else{
$filename=$request->input('company_photo1');
}
//dd($request);
//dd($filename);
$company::where('companies.company_id',$company->company_id)
->update([
'company_photo' => $filename,
'company_name' => request('company_name'),
'company_email' => request('company_email'),
'company_mobile' => request('company_mobile'),
'company_country' => request('company_country'),
'company_state' => request('company_state'),
'company_city' => request('company_city'),
'company_pincode' => request('company_pincode'),
'company_address' => request('company_address'),
'industry_id' => request('industry_id'),
'segment_id' => request('segment_id'),
'company_code' => request('company_code'),
'contact_person'=>request('contact_person'),
]);
The issue you had is you changed the variable $request to $req half way through your code:
Change these lines:
$files = public_path().'/company_photos/'.$req->input('company_photo1');
$file = $req->file('company_photo');
to:
$files = public_path().'/company_photos/'.$request->input('company_photo1');
$file = $request->file('company_photo');
Here is the code with a little refactor:
$filename = $request->input('company_photo1');
if ($request->hasFile('company_photo')) {
$files = public_path().'/company_photos/'.$fileName;
File::delete($files);
$file = $request->file('company_photo');
$file->move(public_path().'/company_photos/', $file->getClientOriginalName());
}

Laravel: How to use Artisan Facade to call terminal commands in Controllers & Models

I have the following 'artisan' command set up
protected $signature = 'make:sub {type} {name}';
The above command works when typed into the terminal.
I want to call it dynamically in a controller. Below is my code:
$name = $request->input("name");
Artisan::call('make:sub', [
'type' => 'origin', 'name' => $name
]);
The above is not working.
I think the issue might be the 'artisan namespace'.
What is the correct 'use namespace' to call artisan commands set up in the command folder?
You got 2 options.
1) at the beginning of the file, you can type: use Artisan;
2) just type :
\Artisan::call('make:sub', [
'type' => 'origin', 'name' => $name
]);

Save multiple upload with clientOriginalName

hy everyone,, i want to upload multiple file with OriginalClientName, save into database with column called "document" but when data saved into database the file when uploading is not same the name,, i am upload file with name "cv bimo.docx", but in database, the name like this:
C:\Users\bimo_an\AppData\Local\Temp\phpAAF.tmp
i already using method getClientOriginalName(),,
this is my Function controller code :
..............................
$uploadFile = $request->file('document');
foreach($uploadFile as $file){
$filename = $file->getClientOriginalName();
$folder[] = $file->storeAs('uploads', $filename);
}
$data = [
'mto_number'=>$request->txtDocNumber,
'item_code'=>$request->txtItemCode[$key],
'required_qty'=>$request->txtRequiredQty[$key],
'spare_qty'=>$request->txtSpareQty[$key],
// 'file' => $path[$key]
'category' => $request->category[$key],
'document' => $file
];
ModelMTOItem::insert($data);
You are passing file Path instead of clientOriginalName
$uploadFile = $request->file('document');
foreach($uploadFile as $file) {
$filename = $file->getClientOriginalName();
$data = [
'mto_number'=>$request->txtDocNumber,
'item_code'=>$request->txtItemCode[$key],
'required_qty'=>$request->txtRequiredQty[$key],
'spare_qty'=>$request->txtSpareQty[$key],
// 'file' => $path[$key]
'category' => $request->category[$key],
'document' => $filename
];
ModelMTOItem::insert($data);
$folder[] = $file->storeAs('uploads', $filename);
}

Laravel Delete Event Listener

A while ago I added all events and listeners related to the auth system, as defined in the docs here, and generated all the listeners. I would now like to use only two listeners and clean up the Listeners folder.
So in EventServiceProvider I've commented out what I don't need:
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
'Illuminate\Auth\Events\Registered' => [
'App\Listeners\LogRegisteredUser',
],
// 'Illuminate\Auth\Events\Attempting' => [
// 'App\Listeners\LogAuthenticationAttempt',
// ],
// 'Illuminate\Auth\Events\Authenticated' => [
// 'App\Listeners\LogAuthenticated',
// ],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessfulLogin',
],
// 'Illuminate\Auth\Events\Failed' => [
// 'App\Listeners\LogFailedLogin',
// ],
// 'Illuminate\Auth\Events\Logout' => [
// 'App\Listeners\LogSuccessfulLogout',
// ],
// 'Illuminate\Auth\Events\Lockout' => [
// 'App\Listeners\LogLockout',
// ],
// 'Illuminate\Auth\Events\PasswordReset' => [
// 'App\Listeners\LogPasswordReset',
// ],
// 'Illuminate\Auth\Events\Verified' => [
// 'App\Listeners\LogVerifiedUser',
// ],
];
I then delete all Listeners in the app/Listeners folder.
If I then run php artisan event:generate I get an error:
ErrorException : include(/PATH
HERE/vendor/composer/../../app/Listeners/LogRegisteredUser.php):
failed to open stream: No such file or directory
What am I missing?
I had the same problem. you may run command
php artisan clear-compiled
or,
composer dump-autoload
and then run php artisan event:generate

how to download PDF in laravel 5.4?

I'm trying to fetch data from database and pass this data to pdf view and download it.
I tried this code but its not working:
Download PDF
Route
Route::get('download-PDF/{id}', 'PDFController#pdf');
Controller
class PDFController extends Controller
{
public function pdf($id){
$getEvent=Event::find($id);
$eventId=$getEvent->id;
if(isset($eventId)) {
$eventData = Event::where('id', $eventId)->first();
$getDays = Day::where('event_id', $eventId)->get();
for ($i = 0; $i < count($getDays); $i++) {
$dayId = $getDays[$i]->id;
$schedule[$i] = DaySchedule::where('day_id', $dayId)->get();
}
}
$pdf=PDF::loadView('pdf',['eventData' => $eventData, 'schedule' => $schedule]);
return $pdf->download('event.pdf');
}
}
Config
'providers' => [
Barryvdh\DomPDF\ServiceProvider::class,
]
'aliases' => [
'PDF' => Barryvdh\DomPDF\Facade::class,
]
Are you getting any exception?
Here is a code I use for generating the pdfs:
Controller:
public function generateReport(TimetableRequest $request, $id) {
$reportData = $this->prepareReportData($id, $request->startDate, $request->endDate);
$pdf = App::make('dompdf.wrapper');
$pdf->loadView('pdf.report', $reportData);
return $pdf->download('report.pdf');
}
Config
'providers' => [
...
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
...
'PDF' => Barryvdh\DomPDF\Facade::class,
]
Route
Route::get('projects/{id}/report', 'Controller#generateReport');

Resources