PHP code example of ahmed-aliraqi / eloquent-media
1. Go to this page and download the library: Download ahmed-aliraqi/eloquent-media library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
> /**
> * Get link of given file name that belongs to this model instance.
> *
> * @param string $name
> * @param string $fallback
> * @return string
> */
> $model->file([$name, $fallback]);
>
> /**
> * Get array of given files name that belongs to this model instance.
> *
> * @param string $name name of folder
> * @return Illuminate\Support\Collection
> */
> public function files($name)
>
> /**
> * Get path of given file name that belongs to this model instance.
> *
> * @param string $name
> * @return string | null
> */
> public function filePath([$name])
>
> /**
> * Determine if the assiciated files is global or not.
> *
> * @param boolean $value
> * @return Illuminate\Database\Eloquent\Model
> */
> public function hasGlobal([$value = true])
>
> $user->hasGlobal()->putFile('default');
>
> /**
> * Determine a filesystem instance.
> *
> * @param string $name
> * @return Illuminate\Database\Eloquent\Model
> */
> public function disk([$name = 'local'])
>
> $user->disk('public')->putFile('photo');
>
return [
// Get users fallback image url.
'users' => 'http://lorempixel.com/grey/800/400/cats/Faker/',
// Get posts fallback image url.
'posts' => 'http://lorempixel.com/grey/800/400/cats/Faker/',
// If You do not run application using artisan serve.
'remove_public_from_url' => false,
];