This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// You may need to use this classes | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\Facades\DB; | |
use Illuminate\Pagination\Paginator; | |
// Searching in segments Model, with pagination, ordering, sorting and searching. | |
$segments = Segment::where('segmentProviderName', $provider); // first where condition | |
$segmentStatuses = config('constants.segment.status'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Role extends Model | |
{ | |
public $timestamps = false; | |
protected $primaryKey = 'roleId'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$currentPage = 3; // You can set this to any page you want to paginate to | |
// Make sure that you call the static method currentPageResolver() | |
// before querying users | |
Paginator::currentPageResolver(function () use ($currentPage) { | |
return $currentPage; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// custom validator in laravel to validate comma separated emails. | |
\Validator::extend("emails", function($attribute, $values, $parameters) { | |
$value = explode(',', $values); | |
$rules = [ | |
'email' => 'required|email', | |
]; | |
if ($value) { | |
foreach ($value as $email) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Middleware: | |
// app\Http\Middleware\log4php.php | |
namespace App\Http\Middleware; | |
use Closure; | |
class log4php | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add "files" element and give path of file there | |
// Do not forget to fire command 'composer dump-autoload' | |
"autoload": { | |
"classmap": [ | |
"database" | |
], | |
"psr-4": { | |
"App\\": "app/" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In composer file exclude file that you want to override. | |
// composer.json | |
// I'm on windows machine so directory separator is \ | |
// If you are on ubuntu/mac it should be like vendor/tymon/jwt-auth... | |
// Tymon is main name space for package, overrides is new folder I have created and copy pasted every files from vendor/tymon | |
// Then remove each file except you wanna override. Maintain folder structure. | |
"exclude-from-classmap": ["vendor\\tymon\\jwt-auth\\src\\Middleware\\BaseMiddleware.php"], | |
"psr-4": { | |
"App\\": "app/", | |
"Tymon\\": "app/overrides/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# File: app\Http\Middleware\CORS.php | |
# Create file with below code in above location. And at the end of the file there are other instructions also. | |
# Please check. | |
namespace App\Http\Middleware; | |
use Closure; | |
class CORS { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add below section to below httpd-vhosts.conf file. | |
# C:\xampp\apache\conf\extra\httpd-vhosts.conf | |
# And restart apache. (Make sure to change paths accordingly) | |
# Then you can navigate laravel from http://project.x | |
<VirtualHost project.x:80> | |
DocumentRoot "C:\xampp\htdocs\_projects\projectx\public" | |
ServerName project.x | |
ServerAlias project.x | |
ServerAdmin admin@localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Migration file | |
// database\migrations\create_users_table.php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreateUsersTable extends Migration | |
{ |