Snippets Collections
/**
 * Carbon example for january 2021 
 */

// first day of month (2021-01-01 00:00:00)
Carbon::now()->firstOfMonth()->startOfDay()

// first day of month in timestamp (1609459200)
Carbon::now()->firstOfMonth()->startOfDay()->timestamp

// last day of month (2021-01-31 23:59:59)
Carbon::now()->lastOfMonth()->endOfDay()

// last day of month in timestamp (1640995199)
Carbon::now()->lastOfMonth()->endOfDay()->timestamp

/**
 * Carbon example for january 1, 2021 
 */

// start of day in date (2021-01-01 00:00:00)
Carbon::now()->startOfDay()
 
// start of day in timestamp (1609459200)
Carbon::now()->startOfDay()->timestamp
 
// end of day in date (2021-01-01 23:59:59)
Carbon::now()->endOfDay()
 
// end of day in timestamp (1609545599)
Carbon::now()->endOfDay()->timestamp
Route::middelware(['auth'])->group(function (){

    Route::get('/', function () {
        return view('welcome');
    });

    Route::get('/dashboard', function (){
        return view('dashboard');
    })->name('dashboard');

});
Route::patch('aluminio/{id}', 'AluminioController@update')->name('aluminio.update');
$tasks = Tasks::find(1);
$newTask = $tasks->replicate();
$newTask->save();
//Multiple relationships:
$books = Book::with('author', 'publisher')->get();

//Nested relationships:
$books = Book::with('author.contacts')->get();
<!-- use enctype -->
<form  action="/route" method="POST" enctype="multipart/form-data">
class="{{ Request::is('products.index') ? 'active' : '' }}"
// url : https://www.example.com/param1/param2/param3
$request()->segment(3); // param3
// config/app.php
'locale' => 'fr',
'fallback_locale' => 'fr',
// replace get()
$products = Product::where('active', 1)->get();

// by paginate()
$products = Product::where('active', 1)->paginate(10);
// config\database.php
'connections' => [
    'mysql' => [
      (...)
      'strict' => true,
    ],
],
$this->validate($request, [
	"field_nullable" => "nullable"
]
/**
* Artisan Command
*/

php artisan make:request RequestName

/**
* Controller Code
*/
// inject filepath to custom request
use App\Http\Requests\RequestName;

// inject custom request as $request
// $request knows about validation and will automatically validate
public function store(RequestName $request)
    {
        Category::create([
            'name' => $request->name
        ]);

        session()->flash('success', 'Category Successfully Created');

        return redirect(route('categories.index'));
    }
    
/**
* Request File
*/
class CreateCategoryRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
    // this is where validation rules are set
        return [
            'name' => 'required|unique:categories'
        ];
    }
}
if (str_contains(url()->current(), '/api')) {

            $finalProperty = [];
            $properties = PropertyListing::orderBy('id', 'DESC')->get(["id","user_id","listing_for","images","address","price","property_type","furnishing_status","facilities"]);
            foreach ($properties as $key => $property){
                // $finalImage['id'] = $property->id;
                // $finalImage['user_id'] = $property->user_id;
                // $finalImage['listing_for'] = $property->listing_for;
                $img_array = explode(',',$property->images);

                $properties[$key]->images = $img_array;

            }
         
            return response()->json(['properties' => $properties, 'success' => 200]);
            
        } else {
            $sliderImages = PropertyListing::all();
            return view('admin.imageslider.index', compact('sliderImages'));
        }
\Log::info(print_r($siteImageUrl, true));
php artisan migrate:refresh --path=/database/migrations/my_migration.php
NotificationFactory::new()->create();



use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Notifications\DatabaseNotification;
use Illuminate\Support\Str;

class NotificationFactory extends Factory
{
    protected $model = DatabaseNotification::class;

    public function definition()
    {
        return [
            'id' => Str::uuid()->toString(),
            'type' => 'App\Notifications\ThreadSubscription',
            'notifiable_id' => function() {
                return auth()->id() ?? User::factory()->create();
            },
            'notifiable_type' => 'App\Models\User',
            'data' => ['message' => 'text']
        ];
    }
}
* Start the VM
	- vagrant up
	- vagrant ssh
* Shutdown and remove everything in memory
	- vagrant halt
* Close the VM for later use
	- vagrant suspend
	- vagrant resume
* Changed the homestead.yaml file?
	- vagrant provision
composer create-project "laravel/laravel=5.1.*" sampleproject
// sending a massage to blade from controller
return redirect()->route('add_item')->with('message', "Category Created Successfully");


//Checking for a message from the blade 
  @if(session()->has('message'))
    <div class="alert alert-success">
        {{ session()->get('message') }}
    </div>
@endif
$entities = $user->entities;
$entityIds = $entities->map( function($entity) {
    return [$entity['id']];
});
Entity::whereIn('id', $entityIds)->deleted();
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
Route::group(['prefix' => '/user'], function () {
    Route::get('/profile', function(){
        return 'Profile';
    });

    Route::get('/password', function(){
        return 'Password';
    });
});
$validatedData = $request->validate([
    'name' => 'required',
    'gender' => 'required',
    'country' => 'required',
    'bod'=>'required',
    'description'=>'required',
]);

Profile::where('user_id',$user_id)->fill([
        'name'=>'name',
        'gender'=>'gender',
        'country'=>'country',
        'bod'=>'bod',
        'description'=>'description',
    ])->save();
Hello, As I read in your description that your company has many php- laravel, javascript projects, I am very interested in working with you. As you can see my profile, I have worked in core PHP, php and wordpress and javascript many times. I can work in this domain.
I know MVCs very well and have experience with them. I have worked with MVC CRUD, routing, integrating frontend technologies like vue.js and angular.js with the MVCs.
I have spent time in Integrating payment gateways in php and laravel.
I am also quiet good in architecturing databases like MySQL.
So overall I feel I will be a great fit t your system if selected once for a project.
If any thing is new for me that has to be implemented in the project then I find it to be a great opportunity of learning and implementation. So you can trust me and keep me as your working partner. You wil find me as a basic need of your development team after I have spent some time working with youl.
I will be waiting for your response.
Thank you.
Kind Regards.
public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required|unique:categories',
        ]);

        $category = Table::findOrFail($id);
        $category->name = $request->name;
        $category->save();
        return redirect()->route('management.table.home')->with('message', "Table Edited Successfully");
    }
   User::create([
           'name' => $request->name,
           'username' => $request->username,
           'email' => $request->email,
           'password' => Hash::make($request->password),

        ]);
<form action="{{ route('posts.likes', $post->id) }}" type="submit" method='post' >
                  @csrf
                  @method('delete')
                <button  type="submit" class="btn btn-primary btn-sm">Dislike</button>
              </form>

//route
Route::delete('/posts/{id}/likes', [PostLikeController::class, 'destroy'])->name('posts.likes');
// In post model are we are checking whether user has liked it:
// contains is a collection method which allows to look at the inside of the collection
// with collectiong you are looking at a particular key (user_id), and checking if the $user->id is within the collection
// then it will return a true or false
 
// POST MODEL: 
public function likedBy(User $user){
      return $this->likes->contains('user_id', $user->id);
    }

//POSTLIKECONTROLLER
 public function store($id, Request $request){
// this is activating when you press the submit button for like

        $this->middleware(['auth']);


        $post = Post::find($id);

        if ($post->likedBy($request->user())){
            return back(); 
        }
        
        $post->likes()->create([
            'user_id' => $request->user()->id,
        ]);
        return back();




 {{ Str::plural('like', $post->likes->count()) }}
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|unique:categories',
        ]);

        Category::create([
            'name' => $request->name,
        ]);
Route::get('/',closure)
<button type="submit" id="customers_filter" onclick="checkWhetherTheTableContainsSearchResults()"
                                class="btn filter-button d-inline-block ml-3">
                                Filter
                            </button>
                            
<input id="search-hidden-input" hidden name="searchValue">

<script>
function checkWhetherTheTableContainsSearchResults() {
        let search = location.search.substring(1)
            searchInputElement = document.getElementById('search-hidden-input');
        
        if(search != '') {
            searchInputElement.setAttribute('value', search);
        }
    }
</script>
    
// If the filter is to work on search results, the original search parameter has to be passed into the request array.
        // Thus, the request array will return more than one parameter 
        // AND
        // one of the parameters will be searchValue
        // WHICH
        // will contain the entire search parameter (key + value)

        if ((count($request->all()) > 1) && (isset($request->searchValue))) {
            if (strpos($request->searchValue, '=')) {
                $string = $request->searchValue;
                $array = explode('=', $string);
                $request->searchValue = $array[1];
            }
        }
"repositories": {
        "webdevmatics/jetstream" : {
            "type": "path",
            "url": "C:\\laragon\\www\\codegenerator\\packages/webdevmatics/jetstream"
        }
    }
star

Thu Jun 17 2021 19:33:02 GMT+0000 (UTC)

#laravel
star

Fri Jun 11 2021 21:12:23 GMT+0000 (UTC) https://dev.to/jeromew90/how-use-sweetalert2-in-laravel-8-using-composer-jki

#laravel
star

Fri Jun 11 2021 21:12:02 GMT+0000 (UTC) https://dev.to/jeromew90/how-to-create-a-multilingual-project-in-laravel-internationalization-i18n-11ol

#laravel
star

Fri Jun 11 2021 21:03:44 GMT+0000 (UTC)

#laravel
star

Fri Jun 11 2021 20:56:52 GMT+0000 (UTC)

#php #laravel
star

Fri Jun 11 2021 20:54:44 GMT+0000 (UTC)

#php #laravel
star

Fri Jun 11 2021 20:53:36 GMT+0000 (UTC)

#php #laravel
star

Sun May 16 2021 17:42:10 GMT+0000 (UTC) https://laravel.com/docs/8.x/validation#form-request-validation

#laravel
star

Mon Apr 19 2021 06:15:12 GMT+0000 (UTC)

#laravel
star

Tue Apr 06 2021 20:22:31 GMT+0000 (UTC) https://www.google.com/search?q

#php #laravel
star

Tue Apr 06 2021 12:42:54 GMT+0000 (UTC) https://stackoverflow.com/questions/47151886/how-can-i-run-specific-migration-in-laravel

#laravel #php
star

Sat Mar 20 2021 06:03:45 GMT+0000 (UTC)

#commandline #laravel
star

Wed Mar 17 2021 08:33:26 GMT+0000 (UTC) https://qiita.com/revenue-hack/items/f90fa5a7d4352d0bbc3f

#laravel #php
star

Fri Mar 12 2021 12:42:08 GMT+0000 (UTC)

#laravel
star

Thu Mar 11 2021 06:41:43 GMT+0000 (UTC) https://laracasts.com/discuss/channels/eloquent/how-to-delete-multiple-records-using-laravel-eloquent

#laravel #php
star

Wed Mar 10 2021 19:39:41 GMT+0000 (UTC) https://es.stackoverflow.com/questions/177114/cómo-redirigir-a-un-usuario-según-su-rol-en-laravel

#rol #laravel
star

Tue Mar 09 2021 14:34:57 GMT+0000 (UTC) https://stackoverflow.com/questions/36460874/laravel-5-errorexception-failed-to-open-stream-permission-denied

#laravel
star

Fri Feb 26 2021 13:51:51 GMT+0000 (UTC)

#laravel
star

Thu Feb 18 2021 15:22:20 GMT+0000 (UTC) https://stackoverflow.com/questions/57985564/laravel5-8-the-get-method-is-not-supported-for-this-route-supported-methods-p

#php #save #laravel
star

Fri Jan 15 2021 13:28:09 GMT+0000 (UTC)

#php #laravel
star

Mon Jan 11 2021 19:39:41 GMT+0000 (UTC)

#laravel
star

Thu Dec 31 2020 11:35:22 GMT+0000 (UTC)

#laravel
star

Mon Dec 28 2020 13:06:02 GMT+0000 (UTC)

#laravel
star

Mon Dec 28 2020 10:39:10 GMT+0000 (UTC)

#laravel
star

Sun Dec 27 2020 11:56:53 GMT+0000 (UTC)

#laravel
star

Sun Dec 27 2020 08:06:01 GMT+0000 (UTC)

#laravel
star

Fri Dec 11 2020 14:49:35 GMT+0000 (UTC) https://www.hoclabs.com/2018/01/14/laravel-roles-y-permisos/

#roles #laravel
star

Tue Dec 01 2020 00:27:14 GMT+0000 (UTC)

#laravel
star

Thu Nov 26 2020 18:43:15 GMT+0000 (UTC) https://virtumedia.wordpress.com/2020/02/27/generar-documentos-pdf-en-laravel-que-incluyan-graficos/

#pdf #laravel
star

Tue Nov 10 2020 15:39:18 GMT+0000 (UTC) https://es.stackoverflow.com/questions/218143/envio-de-mail-con-archivo-adjunto-laravel

#email #laravel
star

Fri Oct 02 2020 03:24:40 GMT+0000 (UTC)

#php #laravel

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension