I don't know how to maintain and work with sessions. As I am a newbie in Laravel 4.
I have created a table as follows:
class Sessions extends Migration
{
Schema::create('sessions', function($table)
{
$table->string('id')->unique();
$table->text('payload');
$table->integer('last_activity');
});
}
Is this correct?
Step 1: php artisan session:table
Step 2: composer dump-autoload
Step 3: php artisan migrate
if you have setup multiple environment on your laravel app then
php artisan migrate --env=ENVIRONMENT_NAME
Step 4: Change the default driver on /app/config/session.php to
'driver'=>'database',
if you have multiple Databases configured on your L4 app, then configure the connection on
/app/config/session.php
'connection'=>CONNECTION_NAME
Related
I have deployed new code to my Forge server. This code includes new routes (web, api, with and without auth).I have run php artisan optimize, but all the new routes return a 404.
The php artisan route:list command display the new routes. I am getting crazy...
Help!?
thanks
OK, someone gave me the solution on Laravel's Slack. I had to relaunch PHP fpm on my Forge server, in order to reset the OPCache.
Running on Laravel 5.8
I am creating a large number of Jobs which I believe should be executed once the queue has been initiated.
My issue is that the jobs get executed then and there when I haven't even started the queue.
They are not even being inserted in to the jobs table created by the migration.
Below are the settings and the piece of code I believe is relevant. Please let me know if more info is needed.
On a fresh installation:
php artisan queue:table
php artisan migrate
.env file
QUEUE_CONNECTION=database
Created the queuedtask
class FulfillmentTask implements ShouldQueue{
//code here
}
Controller
use App\Jobs\FulfillmentTask;
//rest of the class here
public function somefunction(Request $request){
//some code here
//read csv file
foreach ($fileContents as $row){
FulfillmentTask::dispatch($orderId, $client, $request->sendEmail)->onQueue('database');
}
}
Issue is the FulfillmentTask is executed without the queue:work command being given in the terminal.
Any idea on why this is happening?
"database" is a queue connection. Pls dispatch your job to that connection.
FulfillmentTask::dispatch($orderId, $client, $request->sendEmail)->onConnection('database');
And that seems to be the default connection so you just dispatch the job.
FulfillmentTask::dispatch($orderId, $client, $request->sendEmail);
I use vue.js as frontend and laravel as backend.
I want to run artisan command from code when I click button.
My artisan command : "php artisan crawler:crawl 2"
If you are vue and laravel expert It's very foolish question for you.
Please waste your short time to help me.
Make a route to call the function:
Route::get('/crawl', function() {
Artisan::call('crawler:crawl 2');
return 'crawl ran';
});
Make method in view to call it.
I want to access session data from database. Currently, I have changed default setting in session.php to database so that I can capture all the session columns in DB. But now I want to access these in my code. Do I need to create some session model or it's present out of the box just like user.php. Please help me.
You should create sessions table with these commands:
php artisan session:table
composer dump-autoload
php artisan migrate
Or you could manually create migration and run it, an example from documentation:
Schema::create('sessions', function ($table) {
$table->string('id')->unique();
$table->text('payload');
$table->integer('last_activity');
});
After doing that, you can just use sessions as usual with Session:: facade or sessions() helper:
session()->flash('message', 'Success!');
Update
If you need to access table data directly, you could do this:
DB::table('sessions')->get();
Or you could create SessionData() model and do this:
SessionData::all();
I have added:
"laravel/cashier": "^6.0"
to composer.json
and:
Laravel\Cashier\CashierServiceProvider::class,
to app.php in the providers array in the config folder.
I have then run composer update, but if I do:
php artisan
I do not see the cashier command there. Am I missing a step?
That command appears to be removed in 5.2. In looking at the docs for 5.2 they've been updated and there is no longer a reference to using the artisan helper `$php artisan cashier:table users
Rather is seems you must now create the migration manually rather than using a helper. From the docs:
Update the user table migration(or whichever entity you are associating with your billing):
Schema::table('users', function ($table) {
$table->string('stripe_id')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
});
Create a subscriptions table:
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
Then run the migrate command $ php artisan migrate
I wasn't able to find any info on the reason for this change or whether they'll be re-introducing this artisan command in the future. I assume it is by design though.
Click here for more info on creating migrations.
Hope it helps!